const NotFound = { template: '<p>Page not found</p>' }const Home = { template: '<p>home page</p>' }const About = {
template: '<p>about page</p>' }const routes = { '/': Home, '/about': About
}new Vue({
el: '#app',
data: {
currentRoute: window.location.pathname
},
computed: {
ViewComponent () { return routes[this.currentRoute] || NotFound
}
},
render (h) { return h(this.ViewComponent) }
})ViewComponent 这个是什么?function么?为什么不带function关键字?
添加回答
举报
0/150
提交
取消