VUE的路由对应组件如何单独放到某个文件里面
粉丝福利 : 关注VUE中文社区公众号,回复视频领取粉丝福利
<template id="foo">
foo
</template>
<template id="bar">
bar
</template>
const Foo = { template: '#foo' }
const Bar = { template: '#bar' }
const routes = [
{ path: '/foo', component: Foo },
{ path: '/bar', component: Bar }
]
const router = new VueRouter({
routes
})
const app = new Vue({
router
}).$mount('#app')
如果页面很多,那么对应的组件也就好多,能不能把一个组件写到一个对应的html里面,然后根据具体的路由地址动态加载相应的组件,类似angularJS的templateUrl,如果不用webpack,直接用纯html,能实现吗