vue.js - Uncaught ReferenceError: module is not defined at build.js:1 vuejs, webpack, SSR(我使用了 npm script-loader 但没用)
问题描述
集成 bundle.js 时出错,我使用了“script-loader”但没有用。使用 vuejs、vuex、ssr、vuetify、webpack.js 的库
错误:
build.js:1 Uncaught ReferenceError: module is not defined
at build.js:1 .
解决方案
更改脚本
<script src="/dist/build.js"></script>
至
<script nomodule src="/dist/build.js"></script>
在 script 标签中添加 nomodule 属性,这是因为我们在 webpack 配置中使用 libraryTarget: 'commonjs2'
最后我的 index.html 会像
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<script nomodule src="/dist/build.js"></script>
</body>
</html>
笔记:
do not make any changes in src attribute
推荐阅读
- powerbi - 度量中的格式数据与原始计算不同
- r - 用 R 向量中先前数字的修改版本替换 NA
- javascript - 在 D3js 中为每个节点设置图像
- kubernetes - 德鲁伊操作员设置
- javascript - javascript map promises里面
- pdfmake - 子表中的间距 PDFMake
- android - 将 Jetpack-Compose 添加到项目中使用低于 21 的 API
- amazon-s3 - 上传图片 - 数据显示为“���”�!1A“Qaq��2��B�#”,图片为空白 - Next.js 应用程序上传到 DigitalOcean Spaces / AWS S3
- python - 并排渲染多个 pandas html 表
- post - 删除博客文章中的神秘内容