• 카테고리

    질문 & 답변
  • 세부 분야

    프론트엔드

  • 해결 여부

    미해결

VueRouter직접 만들기 ! -> vue@cli3.0에서는 Error가 나는데

18.12.03 23:47 작성 조회수 131

0

뒤늦게 다시 강의를 듣고 있는데요 ;ㅁ;

import Vue from "vue";

import App from "./App.vue";

Vue.config.productionTip = false;

const Login = { template: `<div>Login Page</div>` };

const routes = {

"/": App,

"/login": Login

};

new Vue({

el: "#app",

computed: {

VueComponent() {

return (

routes[window.location.pathname] || {

template: `<div>Page not Found 404</div>`

}

);

}

},

render: h => h(this.VueComponent)

});

Error Message에서는 Computed에서 정의한 VueComponent를 못 찾는데 어떤 문제인지 원인을 못 찾아서 질문드립니다 ㅜ

답변 1

답변을 작성해보세요.

1

랜더함수를 화살표함수에서 객체 메소드로 바꿔보세요.

  render(h) {

return h(this.VueComponent)

}