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關(guān)鍵字?
vue 基礎(chǔ)問題
Qyouu
2018-09-04 17:19:27