【发布时间】:2017-08-26 08:24:19
【问题描述】:
我是 VueJS 的新手,我收到了来自 Vue 的警告,
[Vue warn]: You may have an infinite update loop in a component render function.
当我在 V-bind:style 中使用 V-for 变量时,这是一个示例: 在模板中:
<div v-for="item in model.items" v-bind:class="test(item.result)">
{{item.id}}
</div>
在脚本中:
data() {
return {
accept: false,
not_accept: false,
};
},
methods: {
test(result) {
if (result == 'accept') {
this.accept = true;
this.not_accept = false;
} else if (result == 'Not accept') {
this.accept = false;
this.not_accept = true;
} else {
console.log(result);
}
return {
success: this.accept,
danger: this.not_accept,
};
},
},
【问题讨论】: