我正在嘗試創建一個需要支持系統舊模塊的 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;
})
}
};