0
好吧,我有一個marionette.js控制器,它有一個初始化函數(這個代碼是由別人傳給我的)。在這段代碼中,我發現initialize函數包含一個@options參數。它從何而來?有沒有人知道,例如,在路由器,你可以通過控制器以某種方式任何參數?順便說一句,這是我的文件(我使用require.js和節點):marionette.js控制器this.options參數初始化
define (require, exports, module) ->
# framework dependencies
Marionette = require 'Backbone.Marionette'
# Actions
ShowLandingPageAction = require '../actions/show-landing-page-action'
class LandingPageController extends Marionette.Controller
initialize: (@options)->
@region = options.region
showLandingPage: ->
console.log '--showLandingPage--'
action = new ShowLandingPageAction
action.execute @region
@trigger 'set:active:home'
module.exports = LandingPageController
當初始化控制器時,選項會傳入。所以,當你有新的LandingPageController({test:true})'時,'{test:true}'是你的選擇。 – kalley