DiscoverMeteor/DiscoverMeteor_zh

post_edit.js里面的this._id从何处来的

kaneruan opened this issue · 1 comments

   var currentPostId = this._id;

根据router.js

Router.route('/posts/:_id',{
  name:'postPage',
  data:function () {
        return Posts.findOne(this.params._id);
  }
});

通过路由得到data,根据context(上下文)可知(在meteor中this等价于context data)