我正在尝试实现外部模板(创建HTML页面),但是我无法成功。该页面是一个包含Vue应用程序的ASP.NET MVC页面。
我想将此组件的模板部分移至外部文件,但是无论何时这样做都行不通。
以下内容(以下)可以正常工作,但是由于缺少文本编辑功能,因此不容易维护或构建。
Vue.component('my-component',{模板:'#my-component'}
这是当前的代码,它可以完美地工作:
var foo = Vue.component('foo', {
template:'
<table class="table">
<template v-for="(foo, ColName, index) in foos">
<template v-if="index % 3 == 0">
<tr>
</tr>
</template>
<th>{{ColName}}</th>
<td v-if="foo">{{foo}}</td>
<td v-else> -- </td>
</template>
</table>',
data: function () {
return {
foos: null,
NumColuns: 3
}
},
mounted() {
axios
.get('/api/account/foo/')
.then(response => {
this.foos = response.data
})
.catch(error => {
console.log(error1)
this.errored = true
})
.finally(() => this.loading = false)
}
});
var foo …Run Code Online (Sandbox Code Playgroud)