站内搜索:
首页 >> 前端 >> 内容
ES6模块化操作实例教程

时间:2018/2/6 14:31:01

案例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}`);

ES6模块化操作实例教程

案例2:

temp.js

export default var c = 'js';

index.js

import shy from './temp';
console.log(`shy = ${shy}`);

  • 上一篇:关于绝对禁止页面缓存的Cache-Control之no-store的使用
  • 下一篇:JQuery对象与DOM对象之间的相互转换、如何解决JQuery和其他资源库的冲突?
  • 返回顶部