我正在尝试将 vue-loader 与我的 SPA VUE 应用程序一起使用,但出现以下错误。
ERROR in ./app2.vue
Module build failed (from ./node_modules/vue-loader/dist/index.js):
TypeError: Cannot read properties of undefined (reading 'styles')
at Object.loader (/Users/daniel.bachnov/docker/qhs3-admin/frontend/node_modules/vue-loader/dist/index.js:70:34)
@ ./main.js 1:0-29 14:8-11
webpack 5.74.0 compiled with 1 error and 3 warnings in 3312 msRun Code Online (Sandbox Code Playgroud)
为了消除应用程序代码噪音,我创建了非常简单的组件app2.vue:并尝试将其连接到我的main.js入口点文件。
<script>
export default {
data() {
return {
count: 0
}
}
}
</script>
<template>
<button @click="count++">You clicked me {{ count }} times.</button>
</template>Run Code Online (Sandbox Code Playgroud)
main.js
import App from './app2.vue';
import Router from './router/router.js';
import …Run Code Online (Sandbox Code Playgroud)我正在尝试创建一个 Vue SPA 应用程序,它需要支持系统的旧模块。我想创建向后兼容的组件,它将通过 ajax 请求获取完整的 HTML 模块并将其插入到组件中。
问题在于例外的 HTML 包含应包含的相关脚本。是否有任何选项可以通过 HTML 从服务器注入 JS 文件?
<template>
<div class="container" v-html="html"></div>
</template>
<script>
import { mapState } from "vuex";
export default {
name: "comp",
data() {
return {
html: null
};
},
mounted() {
fetch('http://localhost:8090/api/html/response')
.then(response => {
return response.text();
})
.then(data => {
this.html= data;
})
}
};
Run Code Online (Sandbox Code Playgroud)