エラー:[Vue warn]: Failed to mount component: template or render function not defined.

LaravelのVueコンパイルはうまくいくが、
画面の表示時に、JSのコンソールにエラーが起きた。

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

前提

Laravelのバージョン

$ php artisan --version
Laravel Framework 5.8.36

エラー内容

コンパイルは

このように、問題ない。

ただ、JSコンソールのログに

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

というエラーが発生。

対策

修正内容としては、
resource/js/app.jsのVueのコンポーネントの定義を変更。

Vue.component('sample', require('./components/Sample.vue'));
// 下記のように「default」をつける
Vue.component('sample', require('./components/Sample.vue').default);

就職/転職に向けてスキルを高めるために

プログラミングのスキルを高めるために、

以下のサイトを参考にしてみてください。

おすすめ書籍

コメント一覧

コメントはまだありません。

コメント送信

コメントを残す

広告

おすすめ記事