4
Vue.jsを使用して配列の長さを見るにはどうすればよいですか?Vue.js:配列の長さを参照
Vue.jsを使用して配列の長さを見るにはどうすればよいですか?Vue.js:配列の長さを参照
は、あなたのVMの作成に時計セクションを使用します。
var vm = new Vue({
el: 'body',
data: {
items: []
},
computed: {
item_length: function() {
return this.battle_logs.length;
}
},
watch: {
items: {
handler: function() {
console.log('caught!');
},
deep: true
}
}
});
または計算長さ属性を見る:
vm.$watch('item_length', function(newVal, oldVal) {
console.log('caught!');
});