脚本宝典收集整理的这篇文章主要介绍了模块化管路工具,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
模块化管路工具
一个js文件就是一个模块。
创建两个js文件和一个htML文件,html文件用来打印。
导入,导出:
html文件:
<script src="jspm_packages/system.js"></script>
<script src="config.js"></script>
<script>
System.import('js/main.js');
</script>
首先引入三个js文件。
需要导出的js文件:student.js
let name = "shitu91";
function seyHellow(){
console.log("hellow es6");
}
class Person{
constructor (name,age){
this.name=name;
this.age=age;
}
run(){
console.log("我会跑");
}
}
export {name,seyHellow,Person};
//export:导出;
需要导入的js文件:main.js
import {name,seyHellow,Person} from './student';
console.log(name);//打印shitu91。
seyHellow();//输出hellow es6。
let xs = new Person("宋泽",21);
xs.run();//输出我会跑。
以上是脚本宝典为你收集整理的模块化管路工具全部内容,希望文章能够帮你解决模块化管路工具所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。