Riot.js observable이 다음과 같이 작동합니다. 내 '글로벌 헤더'태그 폭동의 글로벌 범위에서 관찰 riot.store 내부콜백을 통해 매개 변수를 전달하기 위해 Riot.js observable을 얻을 수 없습니다.
는 업데이트 (사용자가 입력 필드에 새 높이를 입력) 및 도착 관찰 트리거 'update_dims'
save_height() {
riot.store.cardHeight = this.refs.input_card_height.value
riot.store.trigger('update_dims')
}
내 'card'태그 내에서 riot.store는 'update_dims'를 수신하고 인터페이스에서 {myCardHeight}를 (를) 성공적으로 업데이트합니다.
// function updates the card height
update_cardHeight() {
this.myCardHeight = riot.store.cardHeight
this.update()
}
// observable runs when triggered and calls above function 'update_cardHeight'
riot.store.on('update_dims',this.update_cardDimensions)
그러나, 나는 riot.store.trigger에서 직접 매개 변수를 전달하려고하면 :
save_height() {
riot.store.cardHeight = this.refs.input_card_height.value
riot.store.trigger('update_dims','450')
}
me.myCardHeight 변수가 새로운 업데이트 된 경우에도 인터페이스를 업데이트하지 않습니다 아래의 관찰 높이 매개 변수 :
me = this
riot.store.on('update_dims', function (height) {
me.myCardHeight = height
console.log(me.myCardHeight)
me.update()
})
어떻게해야할까요?