鍍金池/ 問答/HTML/ ES6Module如何整體加載?

ES6Module如何整體加載?

請問, 現(xiàn)在我有time, route工具函數(shù)文件, 如何統(tǒng)一在index中代理輸出?

time.js中

export cosnt time1
export cosnt time2

route.js中

export cosnt route1
export cosnt route2

如何將time.js與route.js在index.js中整體輸出
然后可以

import {time1} from './index'

我現(xiàn)在使用

export * from './time'
export * from './route'

然后報 exports is not defined?
另外, time與route中有很多函數(shù)的.

回答
編輯回答
裸橙

*符號只用在import中,
如果非要用*,可以

import * as all from './time';
export all

ps:*盡量少用

2017年6月4日 11:41
編輯回答
尐潴豬

是不是代碼里有的export寫成了exports

2018年1月28日 22:47
編輯回答
怪痞
import * as route from './route';
import * as time from './time';

export {
  ...route,
  ...time,
};
2017年12月26日 08:55