文章加密

;

2019年7月23日 星期二

es6 想要觀念

http://es6.ruanyifeng.com/#docs/module-loader

index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://google.github.io/traceur-compiler/bin/traceur.js"></script>
<script src="https://google.github.io/traceur-compiler/bin/BrowserSystem.js"></script>
<script src="https://google.github.io/traceur-compiler/src/bootstrap.js"></script>
<script type="module">
import './Greeter.js';
</script>
</head>
<body>
</body>
</html>

Greeter.js
class Calc {
constructor() {
console.log('Calc constructor');
}
add(a, b) {
return a + b;
}
}

var c = new Calc();
console.log(c.add(4,5));

沒有留言:

張貼留言