index.html中引入一個(gè)下方這種結(jié)構(gòu)的js文件, 但是報(bào)錯(cuò)了
const fn = (() => {
console.log("jinlaile");
})();
export default fn;
原因及解決方案:文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-640473.html
覽器雖然支持了es6,但是不支持es6的Module直接使用,需要在script標(biāo)簽里加上 type=“module”,讓瀏覽器很好的去認(rèn)識(shí)它。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-640473.html
<script type="module" src="js/*.js"></script>
到了這里,關(guān)于Uncaught SyntaxError: Unexpected token ‘export‘的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!