Router

Router?

Rounting?

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) }
})

Render function

Untitled

모든 element는 하나의 node이다. (텍스트 및 주석도 모두 node)

Vue는 수동으로 업데이트 할 필요없다.

수정하고자 하는 HTML 템플릿을 작성하면 대신 업데이트한다.