babeljavascript
babel-loader(內部依賴babel-core)vue
默認java
import [,..xxx] [,..from] './xxx.ext'
export default obj;
聲明式webpack
export var obj = xxx;
export var obj2 = {};
export {stu};
import {obj,obj2,stu} from './xxx.js'; 直接使用obj
默認導出和聲明式導入在使用上的區別es6
{ default:"我是默認導出的結果" import xxx from './cal.js'會獲取到整個對象的default屬性 obj1:"我是聲明式導出1" obj2:"我是聲明式導出2" obj3:"我是聲明式導出3" import {obj1,obj2} obj4:"我是聲明式導出4" } import * as allObj from './cal.js'; 獲取的就是一整個對象
var name = 'abc'; var person = {name}; 簡寫-> var person = {name:name}; 聲明函數 var cal = { add:function(){ return 1; }, add2(){ return 2; }, add3:funtion(n1,n2){ return n1 + n2; }, add4(n1,n2){ 幹掉了function return n1 + n2; } }