我是Ember的新手,我正在编写我的第一个应用程序。我正在使用1.13.11版。
我要做的是覆盖我来自我安装的软件包0.2.1
的版本`import Ember from 'ember'`
`import MultiselectCheckboxOptionComponent from
'ember-multiselect-checkboxes/components/multiselect-checkbox-option'`
multiselectCheckboxesPatch =
name: 'ember-multiselect-checkboxes-patch'
initialize: ->
MultiselectCheckboxOptionComponent.reopen
isSelected: Ember.computed 'value', 'selection', (_, checked) ->
if arguments.length > 1
selected = this.get('selection').contains(this.get('value'))
if checked and not selected
this.get('selection').addObject(this.get('value'))
else if not checked and selected
this.get('selection').removeObject(this.get('value'))
# Added this line to fix variant of https://github.com/emberjs/ember.js/issues/10286
@set('selection', Ember.copy(this.get('selection')))
this.get('selection')?.contains(this.get('value'))
`export default multiselectCheckboxesPatch`
的类中的函数(https://github.com/RSSchermer/ember-multiselect-checkboxes/tree/0.2.1)。
以下是我正在使用的代码:
this.get('selection')
但我面临的问题是selection
似乎未定义。我不明白为什么{{1}}是我正在重新开放的类的属性。
此外,我认为这段代码曾用于旧版本的ember,因为我是从另一个项目中获得的。
谢谢!