私の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()
})
これを行う正しい方法は何ですか?あなたがオブジェクトに格納するのに非常に興味があるなら、私はだ、それの特性と共有ストアを作ることを好むだろう
riot.store = riot.observable();
var me = this
riot.store.on('update_dims', function (height) {
me.myCardHeight = height;
console.log(me.myCardHeight);
me.update();
});
riot.store.trigger('update_dims', 450);
:限り、あなたの店が、これは動作するはず観測可能暴動であるよう