刺激-如何在连接上获取变量集

问题描述

我正在尝试加入stimulusJS

this.itemsList = this.itemsRefList.snapshotChanges().pipe(
  map(changes =>{
   let temp = changes.map(c => ({
      product: c.payload.key,firmware: c.payload.child('latest').val(),ref: c.payload.ref,}))
   //map is done,call other code here
   this.callOtherMethodHere();
   return temp;
  })
);

我希望能够在连接时获取此值,因为我想知道它是否已更改。

解决方法

您的代码在const函数范围内声明了connect()变量。但是您应该改为使用this Stimulus Controller )属性:

...
  connect() {
    this.fooValue = this.fooTarget.value
...

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...