Created
June 28, 2016 12:52
-
-
Save aloerina01/daae2245115da09b723dc59bd1b2b9b9 to your computer and use it in GitHub Desktop.
【失敗例】exports/requireの使い方
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
class ListView { | |
constructor() { | |
this.list = []; | |
}; | |
add(item) { | |
this.list.push(item); | |
return this; | |
}; | |
show() { | |
this.list.forEach(function(e){ | |
console.log(e); | |
}); | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ListView = require('./list-view'); | |
function execute() { | |
var listView = new ListView(); | |
listView.add('item1').add('item2').show(); | |
} | |
execute(); // ListView is not a function となり、コンストラクタを呼べない |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment