vue.jsの初心者です。下のようなコードを書いたのですが、
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link href="in.css" rel="stylesheet"> <title>Document</title> </head> <body> <div id="app"> <input v-model.number="budget">円以下に絞り込む <input v-model.number="limit">件を表示 <p>{{matched.length}}件中{{limited.length}}件を表示中</p> <ul> <li v-for="item in limited" v-bind:key="item.id"> {{item.name}} {{item.price}}円 </li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> <script> var app = new Vue({ el: "#app", data: { order: false, budget: 300, limit:2, list:[ {id:1, name:'りんご', price:200}, {id:2, name:'バナナ', price:100}, {id:3, name:'イチゴ', price:300}] }, computed: { matched: function(){ return this.list.filter(function(e){ return e.price <= this.budget }, this) }, sorted: function(){ return _.orderBy(this.matched, 'price', this.order ? 'desc' : 'asc') }, limited: function(){ return this.sorted.slice(0, this.limit) } }
})
</script> </body> </html> このようなエラーがでできました。 ReferenceError: _ is not defined 調べても中々わからないので質問させていただきます。 どうすればこのエラーを解消できるか、ご教授お願いします。回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。