核心提示:案例1:temp.jsvar a = js;var b = 脚本;var c = web;export {a,b,c}export function add(a,b){return a + b;}//...
案例1:
temp.js
var a = 'js'; var b = '脚本'; var c = 'web'; export { a,b,c } export function add(a,b){ return a + b; } // export { // // 起个语义化名字 // name as a, // // cname as b, // // skill as c // }
index.js
// export 输出操作 // import 引入操作 import {a,b,c} from './temp'; console.log(`a = ${a}`); console.log(`b = ${b}`); console.log(`c = ${c}`);
案例2:
temp.js
export default var c = 'js';
index.js
import shy from './temp'; console.log(`shy = ${shy}`);