Webpack loader to pre-compile Vue 2.0 templates.
npm install vue-template-compiler-loadernpm i vue-template-compiler-loader --save-dev
module.loaders add:
{ test: /\.html$/, loader: 'vue-template-compiler' }
import template from './template.html'
template will be an object
javascript
{
render: Function,
staticRenderFns: Array
}
`
Set render and staticRenderFns properties on a component e.g:
`javascript
// manually
import template from './template.html'
export const myComponent = {
name: 'myComponent',
render: template.render,
staticRenderFns: template.staticRenderFns,
mounted () {}
}
// mixin
import template from './template.html'
export const myComponent = {
name: 'myComponent',
mixins: [template],
mounted () {}
}
// stage2 object spread
import template from './template.html'
export const myComponent = {
name: 'myComponent',
...template,
mounted () {}
}
``