Node.js/nuxt/其他:修订间差异
来自康健生活
| 第14行: | 第14行: | ||
在 nuxt.config.js 中引用会抛错 | 在 nuxt.config.js 中引用会抛错 | ||
{{Warning|ReferenceError: window is not defined}} | {{Warning|ReferenceError: window is not defined}} | ||
需要对引用的代码进行修改 | |||
<syntaxhighlight lang="javascript"> | |||
// 待引入的 js 文件 | |||
module.exports = `if (window) { js文件内容... }`</syntaxhighlight> | |||
2020年9月3日 (四) 03:39的版本
页面组件加载 js
vue-meta
head: {
script: [{ innerHTML: require('./assets/js/flexible'), type: 'text/javascript', charset: 'utf-8'}],
// 不对<script>标签中内容做转义处理
__dangerouslyDisableSanitizers: ['script']
}
head: {
script: [{ src: 'http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js' }],
__dangerouslyDisableSanitizers: ['script']
},
在 nuxt.config.js 中引用会抛错
需要对引用的代码进行修改
// 待引入的 js 文件
module.exports = `if (window) { js文件内容... }`
No categories