"this.get('filter')" 从哪里来?
Where does "this.get('filter')" comes from?
我一直在关注 Embers website 的教程,在某些时候他们会这样做:
let filterInputValue = this.get('value');
let filterAction = this.get('filter');
filterAction(filterInputValue).then((filterResults) => this.set('results', filterResults));
据我所知,this.get('filter') 与 this.filter 或 这个 ['filter'],对吧?我一直在查看他们关于 Component 及其基础对象的文档,因为 attributes/functions 可以被继承,以了解这个 filter 但找不到它。
那么,过滤器从何而来?
指模板中指定的动作。它位于您链接页面的第一个代码块的 rentals.hbs
中:
{{#list-filter
filter=(action 'filterByCity')
编辑:回答你关于 this.prop 与 get(this, prop) 或 this.get(prop) 的问题,this.prop 是不一样的。但是,很快就会这样。查看 this RFC 了解更多信息
我一直在关注 Embers website 的教程,在某些时候他们会这样做:
let filterInputValue = this.get('value');
let filterAction = this.get('filter');
filterAction(filterInputValue).then((filterResults) => this.set('results', filterResults));
据我所知,this.get('filter') 与 this.filter 或 这个 ['filter'],对吧?我一直在查看他们关于 Component 及其基础对象的文档,因为 attributes/functions 可以被继承,以了解这个 filter 但找不到它。
那么,过滤器从何而来?
指模板中指定的动作。它位于您链接页面的第一个代码块的 rentals.hbs
中:
{{#list-filter
filter=(action 'filterByCity')
编辑:回答你关于 this.prop 与 get(this, prop) 或 this.get(prop) 的问题,this.prop 是不一样的。但是,很快就会这样。查看 this RFC 了解更多信息