es6-2 模块化开发

index.html

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>es6模块化开发</title>
		<script src="js/module2.js" type="module"></script>
	</head>
	<body>
	</body>
</html>

module1.js

export var x = 100;
export var str = "hello";

export function test(){
	console.log("aaaa");
}

module2.js

import {x,str,test} from './module1.js';

console.log(x);
console.log(str);
test();

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/gcyqweasd/article/details/113797120