【发布时间】:2017-01-02 03:32:37
【问题描述】:
我有一个包含数组的对象,该数组在完成一定数量的逻辑后递增。
Vue.js 似乎没有捕捉到这个增量并将其显示到视图中。
HTML:
<div id="demo">
<p>{{points}}</p>
</div>
JS:
function Board()
{
this.team1 = {pointsMade:[0]};
}
var newBoard = new Board();
newBoard.team1.pointsMade[0]++
new Vue({
el: '#demo',
data: {
points: newBoard.team1.pointsMade
}
})
setTimeout(newBoard.team1.pointsMade[0]++,1000)
我有一个概述问题的JSFiddle。
可以看到setTimeout(newBoard.team1.pointsMade[0]++,1000)运行后,值应该是'2',但只显示在'1'。我在这里错过了什么?
【问题讨论】:
-
@AndyRay 太好了,但是我对 Vue.js 还是很陌生,并且对文档感到困惑,您将如何为我描述的问题实施解决方案?
标签: javascript html vue.js