Javascript ember api actions collectionAction引发错误无法读取未定义的属性“构造函数”
我有一个带有collectionAction的模型邮箱Javascript ember api actions collectionAction引发错误无法读取未定义的属性“构造函数”,javascript,ember.js,ember-cli,Javascript,Ember.js,Ember Cli,我有一个带有collectionAction的模型邮箱 import DS from 'ember-data' import { collectionAction } from 'ember-api-actions' export default DS.Model.extend({ mailbox: DS.attr(), //display only pin: DS.attr(), download: collectionAction({ path: 'greeting'}) })
import DS from 'ember-data'
import { collectionAction } from 'ember-api-actions'
export default DS.Model.extend({
mailbox: DS.attr(), //display only
pin: DS.attr(),
download: collectionAction({ path: 'greeting'})
})
当我试图从我的组件调用download时,我得到一个错误
import Component from '@ember/component'
import Ember from 'ember'
import FileSaverMixin from 'ember-cli-file-saver/mixins/file-saver'
export default Component.extend(FileSaverMixin, {
hifi: Ember.inject.service(),
notifications: Ember.inject.service('notification-messages'),
startPlay: true,
changeset: {},
actions: {
toggle () {
let hifi = this.get('hifi')
if (this.get('startPlay')){
this.set('startPlay', false )
this.get('changeset').get('download')().then((content) => {
this.saveFileAs(this.get('filename'), content, this.get('contentType'))
})
this.get('play')()
} else {
hifi.togglePause();
}
},
}
})
错误为未捕获的TypeError:无法读取未定义的属性“构造函数”。
我查了一下我的cod/它是一样的
但是我的鳕鱼不起作用。请帮帮我。我不明白怎么回事。根据我从你的帖子中可以看出,似乎“下载”不是调用collectionAction的正确方法。这可能是您的全部或部分问题。您应该能够通过使用以下命令来执行此操作:
this.get('change').download().then(() => {});
使用ember变更集插件是一个麻烦。当我将模型放在我的组件中而不是变更集模型中时,一切都正常。保罗,谢谢你努力帮助我。问题解决。没问题。感谢您发布正确的解决方案。