我正在尝试创建一个需要支持系统旧模块的 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;
})
}
};