Я хотел бы отобразить html-код внешнего html-файла в шаблоне компонента vue.
<template>
<div class = "content">
<pre>
<code>
{{readFile('./code/code.html')}}
</code>
</pre>
</div>
</template>
<script>
export default {
methods: {
readFile: function(url) {
return 'html code of html file.'
}
}
}
</script>



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


<div v-html = "compiledHtml"></div>
data: function() {
return {
fileName: "terms.html",
input: ""
};
},
created() {
this.fileName = this.$route.params.fileName;
this.loadFile()
}
computed: {
compiledHtml: function() {
return this.input;
}
},
methods: {
loadFile() {
axios({
method: "get",
url: "../../static/" + this.fileName
})
.then(result => {
this.input = result.data;
})
.catch(error => {
console.error("error getting file");
});
}
},
трюк - это вычисляемое свойство
в файле чтения вы должны выполнить вызов xhr (ajax, fetchAPI, axios) на свою html-страницу и просто использовать ответ ...