[英]Uncaught TypeError: this.source is not a function coffeescript error
[英]Coffeescript Uncaught TypeError: object is not a function Error
知道為什么@layout = @getLayoutView()
行拋出Uncaught TypeError: object is not a function
錯誤嗎? 我似乎無法弄清楚。 與往常一樣,非常感謝您的幫助!
list_controller.js.coffee:
@Demo.module "UsersApp.List", (List, App, Backbone, Marionette, $, _) ->
List.Controller =
listUsers: ->
users = App.request "user:entities"
@layout = @getLayoutView()
App.mainRegion.show @layout
getLayoutView: ->
new List.Layout
list_view.js.coffee:
@Demo.module "UsersApp.List", (List, App, Backbone, Marionette, $, _) ->
List.Layout = new Marionette.LayoutView
template: "users/list/templates/list_layout"
編輯添加路由邏輯
user_app.js.coffee:
@Demo.module "UsersApp", (UsersApp, App, Backbone, Marionette, $, _) ->
class UsersApp.Router extends Marionette.AppRouter
appRoutes:
"users": "listUsers"
API =
listUsers: ->
UsersApp.List.Controller.listUsers()
App.addInitializer ->
new UsersApp.Router
controller: API
app.js.coffee:
@Demo = do (Backbone, Marionette) ->
App = new Marionette.Application
App.rootRoute = "users"
App.addRegions
headerRegion: "#header-region"
mainRegion: "#main-region"
footerRegion: "#footer-region"
App.addInitializer ->
App.module("HeaderApp").start()
App.module("FooterApp").start()
App.on "start", ->
if Backbone.history
Backbone.history.start()
@navigate(@rootRoute, trigger: true) if @getCurrentRoute() is ""
App
我猜您應該從“ Marionette.LayoutView”擴展List.Layout,但是這里的代碼段創建了“ Marionette.LayoutView”的實例。 編碼
List.Layout = new Marionette.LayoutView
template: "users/list/templates/list_layout"
本來應該
class List.Layout extends Marionette.LayoutView
template: "users/list/templates/list_layout"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.