function test() {
document.getElementById('test').innerHTML--
}
module.exports = test
这样可以用标签引用啵
<script src="./assets/js/index.js"></script>
报错module is not defined
请问是什么问题
function test() {
document.getElementById('test').innerHTML--
}
module.exports = test
这样可以用标签引用啵
<script src="./assets/js/index.js"></script>
报错module is not defined
请问是什么问题
现代浏览器已支持export,import,所以script标签内应该这样使用:
<script type="module">
import test from './a.js'
test();
</script>
a.js代码如下:
export default function() {
console.log('1')
}
13 回答12.9k 阅读
7 回答2.1k 阅读
3 回答1.3k 阅读✓ 已解决
2 回答1.3k 阅读✓ 已解决
6 回答1.2k 阅读✓ 已解决
6 回答1.1k 阅读
2 回答1.3k 阅读✓ 已解决
node.js的语法又不是js的语法
CommonJS规范 node.js
AMD规范 浏览器
CMD 浏览器
ES6模块化 浏览器 or node