【发布时间】:2021-05-17 12:33:27
【问题描述】:
我有一个定义为0的数字,还有一个增加数字的增加方法……
但是当我使用这些时,它会说
[Vue 警告]:组件渲染函数中可能存在无限更新循环。
html:
<div id="app">
{{ increase() }}
<p>{{ number }}</p>
</div>
js:
var application = new Vue({
el: "#app",
data: {
number: 0,
},
methods: {
increase: function() {
this.number++
},
},
});
【问题讨论】:
-
您想在点击时调用
increase方法吗?如果是,则将其定义为<div id="app" @click="increase">