我是Vue.js的新手,我已经使用了AngularJS一段时间,而且我们习惯于加载模板,例如,
template: '/sometemplate.html',
controller: 'someCtrl'
Run Code Online (Sandbox Code Playgroud)
我们怎么能在Vue中做这样的事情,而不是像这样在JavaScript中保存大型HTML模板,
new Vue({
el: '#replace',
template: '<p>replaced</p>'
})
Run Code Online (Sandbox Code Playgroud)
对于小模板来说这是可以的,但对于大模板这是否实用?
有没有办法加载外部模板HTML或在像Vue中的脚本标记中使用HTML模板?
<script type="x-template" id="template>HTML template goes here</html>
Run Code Online (Sandbox Code Playgroud)