gpt4 book ai didi

data-binding - 如何在 riot js 中进行变量更新

转载 作者:行者123 更新时间:2023-12-04 22:45:00 26 4
gpt4 key购买 nike

喜欢 riot js 但是为什么在下面的代码示例中页面上的“Hello 0”没有增加,现在有什么解决方法?

<my-app>
<p>Hello {myNumber}</p>
this.myNumber = 0;
var thisApp = this;
setInterval(
function(){
thisApp.myNumber++;
},
1000
);
</my-app>

最佳答案

在函数里面添加

thisApp.update();

从 2.2.2-beta 版开始,没有办法在 riot js 中添加和配置脏检查。

您无需调用 update()在执行您的
  • 最外层脚本
  • 通过 riot js html 模板表达式执行的事件函数

  • ...因为 riot js 自动调用 update()在执行那些之后。

    关于data-binding - 如何在 riot js 中进行变量更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31351743/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com