0
反応するバールの値を取得しようとしているときに私はUncaught TypeError: Cannot read property 'chapter' of null
を得ています。私はSessionと全く同じことをやっていて、うまくいきます。だから、私は間違っていることについて混乱している。おそらく値は間違った時間に設定されているでしょうか?流行の反応しているバールが設定されていない
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var'
import { Stories } from '/imports/collections/stories.js';
/* Story */
Template.story.onCreated(function(){
// Set the current chapter
this.chapter = new ReactiveVar(0);
this.page = new ReactiveVar(0);
});
Template.story.onRendered(function(){
/* Show the first fragment */
page.addEventListener('changed', function(event) {
console.log(Template.instance().chapter.get());
....
イベントが発生していますが、チャプターのインスタンスがonCreatedに設定されていません。
私はここで間違っていますか?
これが働いていました。ありがとうございました! 私はここで何が欠けていますか? Template.instance()。chapter.get() '' 'と' '' instance.chaper.get() '' 'の違いは何ですか? –
イベントリスナーのコールバックに入ると、テンプレートの範囲が失われてしまいます。だから私はちょうど参照としてそれを保存し、閉鎖を介してアクセスします。 – zim
私は "' 'Template''のスコープがもっと広がっていたと思います。ありがとう!! –