所以我有義務將es5轉換爲es6模塊。單個模塊中的角度1.x和es6多個常量
如果ES6的角度模塊中存在多個常量,那麼如何導出/導入角度常量模塊?
E.g. constants.js
export default angular.module('myConstants', [])
.constant('foo', {result: 'bar'})
.constant('blah', {result: 'bar'});
service.js
import foo from './constants';
import blah from './constants'; // Tried this. This won't work
這是否意味着我有我的常量拆分成獨立的模塊?或者我應該使用const關鍵字將它們轉換爲ES6常量?使用的WebPack和巴貝爾裝載機
附註:
P.p.s我必須使用僞代碼,因爲我無法粘貼工作代碼。
該導出語句是語法錯誤。你的意思是使用'export default'嗎? – Bergi
當你有ES6模塊時,爲什麼要使用角度模塊? – Bergi
@Bergi是的,謝謝。我已經更新了它。 – chrisjlee