通常可以用
@constructor.name
取得但 IE並不支援JS裡的 function.name
所以可以改以
@constructor.toString().match(/^function\s(.+)\(/)[1]
@constructor.name
取得@constructor.toString().match(/^function\s(.+)\(/)[1]
switch layout
when 'case1'
_path= '_v/View1'
when 'case2'
_path= '_v/View2'
else
_path= '_v/View3'
require [_path],(View)=>
view= new View
el:'#container'
@dispatchEvent 'ready'
@collection.comparator=(_model)=>
switch @sortType
when 'name'
_model.get('songName')
when 'artist'
_model.get('artistName')
when 'album'
_model.get('albumName')
3.設定監聽 當排序完成會被觸發@collection.comparator=(_model)=>
switch @sortType
when 'name'
_model.get('songName')
when 'artist'
_model.get('artistName')
when 'album'
_model.get('albumName')
4.執行排序@collection.sort()
file:myclass.coffee
class MyClass
constructor:(@name)->
module.exports=MyClass
2.使用Rocker=require('./myclass')
rocker=new Rocker()
file:myclass.coffee
class MyClass
constructor:(@name)->
class MyClass2
exports.Rocker=MyClass
exports.Tester=MyClass2
2.使用MyRocker= require('./myclass').Rocker
MyTester= require('./myclass').Tester
rocker=new MyRocker('oz')