es6 vs commonjs
原创
©著作权归作者所有:来自51CTO博客作者wx634d08b5232a4的原创作品,请联系作者获取转载授权,否则将追究法律责任
'use strict'
export function showMe() {
alert("es6");
};
class logging {
constructor() {
alert("es6 class");
}
ha() {
console.log("fff");
}
}
export const log = new logging();
#......
import { showMe, log } from './es6.js';
showMe();
log.ha();
'use strict'
function showMeC() {
alert("commonjs");
}
module.exports = {
showMeC: showMeC,
};
# ......
const { showMeC } = require('./commonjs.js');
showMeC();
commonjs