【发布时间】:2018-07-14 13:33:39
【问题描述】:
在我的应用程序中,我有一个组件,我希望在组件之外拥有他的属性。 我创建了这个例子:
Vue.component('vue-table', {
template: '<div><template v-for="row in apiData.content"><span>{{row.name}}</span><button @click="remove(row)">remove</button><br></template></div>',
data: function() {
return {
//this data will be loaded from api
apiData: {
total: 20,
content: [
{id: 10, name: 'Test'},
{id: 12, name: 'John'},
{id: 13, name: 'David'},
],
},
};
},
methods: {
remove(row) {
this.apiData.content.splice(this.apiData.content.indexOf(row), 1);
},
},
})
new Vue({
el: '#app',
methods: {
isActive(){
//how can i check if in vue-table apiData.content > 0?
//return this.$refs.table.apiData.data.length > 0;
},
},
})
http://jsfiddle.net/z11fe07p/2806/
所以我想在 vue-table apiData.content.length > 0 的长度时将 span 类更改为“活动”
我该怎么做?
【问题讨论】:
标签: vue.js vue-component watch