Riot.js 编译并装入的标记不';似乎没有更新

Riot.js 编译并装入的标记不';似乎没有更新,riot.js,Riot.js,编译并装入一个读取从其父级传递的opts属性的标记后,当传递的opt被更新时,我无法让读取该属性的子级进行更新 要查看问题运行的演示,请执行以下操作: git clone https://github.com/shouston3/learn-riot.git && cd learn-riot/demo-problem npm i && npm start visit http://localhost:3333 当计数器递增时,未编译的计数器将更新 但编译后的

编译并装入一个读取从其父级传递的opts属性的标记后,当传递的opt被更新时,我无法让读取该属性的子级进行更新

要查看问题运行的演示,请执行以下操作:

git clone https://github.com/shouston3/learn-riot.git && cd learn-riot/demo-problem

npm i && npm start

visit http://localhost:3333
当计数器递增时,未编译的计数器将更新

但编译后的一个不会

我怎样才能让它更新


提前感谢您的帮助

我简化了您的代码,假设您希望同时增加父标记和子标记。我删除了var self=this,而不是本例中不需要的,并更改了这个赋值
self.opts.count=++self.opts.count
to
this.count=++this.count

问题是您试图将数据分配给opts,但实际情况并非如此。要将数据传递给子级,只需传递标记
中的参数(可能最好为标记和变量使用不同的名称)

这是密码

  <demo>
    <button onclick={increment}>increment</button>

    <h1>Uncompiled count: {this.count}</h1>

    <count count={this.count}></count>

    this.count = 0;

    increment () {
      this.count = ++this.count;
      console.log('count: ', this.count);
      this.update();
    }

  </demo>

增量
未编译计数:{this.count}
此值为0.count;
增量(){
this.count=++this.count;
console.log('count:',this.count);
这个.update();
}
这是一个例子

我简化了代码,假设您希望同时增加父标记和子标记。我删除了var self=this,而不是本例中不需要的,并更改了这个赋值
self.opts.count=++self.opts.count
to
this.count=++this.count

问题是您试图将数据分配给opts,但实际情况并非如此。要将数据传递给子级,只需传递标记
中的参数(可能最好为标记和变量使用不同的名称)

这是密码

  <demo>
    <button onclick={increment}>increment</button>

    <h1>Uncompiled count: {this.count}</h1>

    <count count={this.count}></count>

    this.count = 0;

    increment () {
      this.count = ++this.count;
      console.log('count: ', this.count);
      this.update();
    }

  </demo>

增量
未编译计数:{this.count}
此值为0.count;
增量(){
this.count=++this.count;
console.log('count:',this.count);
这个.update();
}
这是一个例子