[ES6] Export class and variable

Export variable:

export const MAX_USERS = 3;
export const MAX_REPLIES = 3;

Export default class:

export default class FlashMessage {
constructor(message){
this.message = message;
} renderAlert(){
alert(`${this.message} from alert`);
} renderLog(){
console.log(`${this.message} from log`);
}
} ------------------------------- import anythingYouWantToNameit from './flash-message';

Export named class:

class FlashMessage {

  constructor(message){
this.message = message;
} renderAlert(){
alert(`${this.message} from alert`);
} renderLog(){
console.log(`${this.message} from log`);
} export { FlashMessage }; } --------------------------------- import FlashMessage from './flash-message';
上一篇:数据分析第三篇:Numpy知识点


下一篇:Cocos游戏引擎,让小保安成就大梦想