相关推荐recommended
Uncaught SyntaxError: Unexpected token ‘export‘
作者:mmseoamin日期:2024-04-30

index.html中引入一个下方这种结构的js文件, 但是报错了

const fn = (() => {
  console.log("jinlaile");
})();
export default fn;

Uncaught SyntaxError: Unexpected token ‘export‘,在这里插入图片描述,第1张

原因及解决方案:

览器虽然支持了es6,但是不支持es6的Module直接使用,需要在script标签里加上 type=“module”,让浏览器很好的去认识它。

 

上一篇:【vue2】近期bug收集与整理02

下一篇:没有了