use traceur in ES6
2015-07-28 22:03
204 查看
1 Index.html
2 cal.js
3 profile.js
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> </head> <body> </body> <!-- 加载Traceur编译器 --> <script src="http://google.github.io/traceur-compiler/bin/traceur.js" type="text/javascript"></script> <!--<!– 将Traceur编译器用于网页 –>--> <script src="http://google.github.io/traceur-compiler/src/bootstrap.js" type="text/javascript"></script> <!-- 打开实验选项,否则有些特性可能编译不成功 --> <script> traceur.options.experimental = true; </script> <script type="module" src="cal.js"> </script> </html>
2 cal.js
/** * Created by Jackey Li on 2015/7/26. */ import {Hello} from './profile.js'; class Calc { constructor(){ this.hello = new Hello(); this.hello.sayHi(); console.log('Calc constructor'); } add(a, b){ return a + b; } } var c = new Calc(); console.log(c.add(4,5));
3 profile.js
/** * Created by Jackey Li on 2015/7/26. */ export class Hello{ constructor(){ } sayHi(){ console.log('hi'); } }
相关文章推荐
- linux--正则表达式
- ThreadPoolExecutor
- DFS大法好之我都不会做系列
- C语言之函数调用15—递归法求哥德巴赫猜想
- Majority Element
- python基础补充
- 订单快递单号及查询快递进度
- C++ IO类
- css链接和内容
- Dump文件
- Nginx 笔记与总结(5)访问日志管理:计划任务 + 日志切割
- 自定义字体
- 在html借助元素特性存储信息
- UI005---延迟加载
- 天才的大三暑假修行之旅.捕鱼达人
- Python高效率编程的8条箴言
- 我遇见的关于android studio 导入studio项目常见问题
- 依据Uri获得sd卡图片
- 几种java通信(rmi,http,hessian,webservice)协议性能比较
- secureCRT连接后提示-bash: User: command not found的解决办法