Ember 控制器中的 Mixin 未定义
Ember Mixin undefined in controller
可能是个愚蠢的问题,但似乎无法正确回答。我有一些我想在两个控制器之间共享的操作,所以我想在 mixin 中定义它们,然后将它们包含在控制器中。我的语法与我在指南中看到的相符:
mixins/shared.js.coffee
Dashboard.Shared = Ember.Mixin.create
actions:
showTab: (tab) ->
//handle action here
controllers/messages/messages_contacts_show_controller.js.coffee
Dashboard.MessagesContactsShowController = Ember.ObjectController.extend Dashboard.Shared,
加载应用程序时,出现此错误:
Uncaught Error: Assertion Failed: Expected hash or Mixin instance, got [object Undefined]
我不确定如何在控制器之前加载这个 mixin,因为我的文件是分开的(参考:what is the correct way to use coffeescript with ember´s Mixins?已经尝试导入它但不断从 coffeescript 中收到 "reserved word" 错误。
import { Shared } from './mixins/shared'
和
import Shared from "./mixins/shared"
在将使用它的控制器之前加载 mixin 的正确方法是什么?
我正在使用 Ember 1.8.1
假设您 require
您的 JS 文件在一些主要的 App
脚本中,问题很可能是 "MessagesContactsShowController" 在 "Shared" 之前排序。当您使用通配符 require
时,文件将按字母顺序包含。您可以尝试将 Shared
mixin 移动到不同的文件夹,然后更改 require
语句的顺序,以便在 MessagesContactsShowController
之前处理它
可能是个愚蠢的问题,但似乎无法正确回答。我有一些我想在两个控制器之间共享的操作,所以我想在 mixin 中定义它们,然后将它们包含在控制器中。我的语法与我在指南中看到的相符:
mixins/shared.js.coffee
Dashboard.Shared = Ember.Mixin.create
actions:
showTab: (tab) ->
//handle action here
controllers/messages/messages_contacts_show_controller.js.coffee
Dashboard.MessagesContactsShowController = Ember.ObjectController.extend Dashboard.Shared,
加载应用程序时,出现此错误:
Uncaught Error: Assertion Failed: Expected hash or Mixin instance, got [object Undefined]
我不确定如何在控制器之前加载这个 mixin,因为我的文件是分开的(参考:what is the correct way to use coffeescript with ember´s Mixins?已经尝试导入它但不断从 coffeescript 中收到 "reserved word" 错误。
import { Shared } from './mixins/shared'
和
import Shared from "./mixins/shared"
在将使用它的控制器之前加载 mixin 的正确方法是什么?
我正在使用 Ember 1.8.1
假设您 require
您的 JS 文件在一些主要的 App
脚本中,问题很可能是 "MessagesContactsShowController" 在 "Shared" 之前排序。当您使用通配符 require
时,文件将按字母顺序包含。您可以尝试将 Shared
mixin 移动到不同的文件夹,然后更改 require
语句的顺序,以便在 MessagesContactsShowController