質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Vue.js

Vue.jsは、Webアプリケーションのインターフェースを構築するためのオープンソースJavaScriptフレームワークです。

Laravel 5

Laravel 5は、PHPフレームワークLaravelの最新バージョンで、2014年11月に発表予定です。ディレクトリ構造がが現行版より大幅に変更されるほか、メソッドインジェクションやFormRequestの利用が可能になります。

Q&A

解決済

1回答

786閲覧

Vue.js Componentsが反映されない

h.yamazaki

総合スコア20

Vue.js

Vue.jsは、Webアプリケーションのインターフェースを構築するためのオープンソースJavaScriptフレームワークです。

Laravel 5

Laravel 5は、PHPフレームワークLaravelの最新バージョンで、2014年11月に発表予定です。ディレクトリ構造がが現行版より大幅に変更されるほか、メソッドインジェクションやFormRequestの利用が可能になります。

0グッド

1クリップ

投稿2019/05/18 08:15

LaravelにVue.jsを導入してオリジナルサービスを練習で作っているのですが、
bladeにapp.jsで登録しているComponentsが画面に表示されません。
Consoleのエラーをみると以下のように表示されているのですが、自己解決ができなかったので、質問させていただきます。
コードも伏せて載せておきますのでどうかよろしくお願いします。

エラー文

[Vue warn]: Unknown custom element: <card-list> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

実際のコード

show.blade.php

PHP

1@extends('layouts.app') 2 3@section('header_menu') 4@parent 5 6<body class="{{$board->color}}"> 7 @section('content') 8 <div id="app"> 9 <card-list></card-list> 10 </div> 11 @endsection 12</body> 13

app.js

Javascript

1 2/** 3 * First we will load all of this project's JavaScript dependencies which 4 * includes Vue and other libraries. It is a great starting point when 5 * building robust, powerful web applications using Vue and Laravel. 6 */ 7 8require('./bootstrap'); 9 10window.Vue = require('vue'); 11 12/** 13 * The following block of code may be used to automatically register your 14 * Vue components. It will recursively scan this directory for the Vue 15 * components and automatically register them with their "basename". 16 * 17 * Eg. ./components/ExampleComponent.vue -> <example-component></example-component> 18 */ 19 20// const files = require.context('./', true, /.vue$/i) 21// files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default)) 22 23Vue.component('example-component', require('./components/ExampleComponent.vue').default); 24Vue.component('card-list', require('./components/CardList.vue').default); 25 26/** 27 * Next, we will create a fresh Vue application instance and attach it to 28 * the page. Then, you may begin adding components to this application 29 * or customize the JavaScript scaffolding to fit your unique needs. 30 */ 31 32const app = new Vue({ 33 el: '#app' 34});

CardList.vue

<template> <div class="container"> <div class="row justify-content-center"> <div class="col-md-8"> <div class="card card-default"> <div class="card-header">Card-List</div> <div class="card-body"> Card-List </div> </div> </div> </div> </div> </template> <script> export default { mounted() { console.log('Component mounted.') } } </script>

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

そもそも、app.jsを編集した後に、npm run devをしていませんでした。

投稿2019/05/18 09:27

h.yamazaki

総合スコア20

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問