| VueRouter |
|---|
| + options + data + routeMap |
| + Constructor(Options): VueRouter _ install(Vue): void + init(): void + initEvent(): void + createRouteMap(): void + initComponents(Vue): void |
完整版vue同时包含 运行时(runtime)和 编译器(compiler),体积比运行时版大10k左右,程序运行时会把模板转换成 render 函数。
配置vue.config.js:
module.exports = {
// 是否使用包含运行时和编译器的Vue构建版本
// 设置为true后就可以在Vue组件中使用`template`选项了
// 但是这会让你的应用额外增加10kb左右(编辑器)
runtimeCompiler: true // 默认false
}不支持template模板,需要打包时提前编译,所以需要自己手写 render 函数。
Vue.component('router-link', {
props: {
to: String
},
render(h) {
return h('a', {
attrs: {
href: this.to
}
}, [this.$slots.default])
}
})