LoginSignup
4
5

More than 3 years have passed since last update.

[Vue warn]: Failed to mount component のエラー解決メモ

Last updated at Posted at 2019-09-15

Laravel + Vue で開発していて

遷移をVue Routerでおこなっていたら
以下のようなエラーに詰まった
スクリーンショット 2019-09-16 2.50.57.png

app.js:41007 [Vue warn]: Failed to mount component: template or render function not defined.

found in

---> <Anonymous>
       <Root>

マウントに失敗したと言っている。app.jsをみてみる。

app.js

let routes = [
  { path: '/dashboard', component: require('./components/Dashboard.vue')},
  { path: '/profile', component: require('./components/Profile.vue')}
]

結論からいうとこのソースを下のソースに変える。

app.js
let routes = [
  { path: '/dashboard', component: require('./components/Dashboard.vue').default },
  { path: '/profile', component: require('./components/Profile.vue').default }
]

.defaultをつけるようにすると遷移がうまくいった。

4
5
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5