LaravelでVue.jsが動かないです。
10個以上のサイトを参考にしたのですが、うまく動かないので、質問させていただきました。
回答いただけるととても助かります。。。
htmlファイル
テンプレートファイル
default.html
1<!DOCTYPE html> 2<html lang="ja"> 3<head> 4 <head> 5 <meta charset="utf-8"> 6 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 7 <meta name="csrf-token" content="{{ csrf_token() }}"> 8 <title>練習!</title> 9 <link rel="stylesheet" type="text/css" href="/css/app.css"> 10 <!-- Bootstrap CSS --> 11 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 12 <!-- jQuery --> 13 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 14 <!-- Bootstrap JavaScript--> 15 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 16 <link href="{{ mix('css/app.css') }}" rel="stylesheet" type="text/css"> 17 </head> 18 <body> 19 @include('parts.header') 20 <div class="container"> 21 @yield('content') 22 </div> 23 @include('parts.footer') 24 <script src="{{ mix('js/app.js') }}"></script> 25 </body> 26</html> 27
test.htmlのファイル
test.html
1@extends('layouts.default') 2@section('content') 3<div class="container"> 4 <div class="w-75 mx-auto text-center"> 5 <div id="app"> 6 <example-component></example-component> 7 </div> 8 <div> 9</div> 10@endsection
jsファイル
app.js
/** * First we will load all of this project's JavaScript dependencies which * includes Vue and other libraries. It is a great starting point when * building robust, powerful web applications using Vue and Laravel. */ require('./bootstrap'); require('./test'); window.Vue = require('vue'); /** * The following block of code may be used to automatically register your * Vue components. It will recursively scan this directory for the Vue * components and automatically register them with their "basename". * * Eg. ./components/ExampleComponent.vue -> <example-component></example-component> */ // const files = require.context('./', true, /.vue$/i) // files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default)) Vue.component( 'example-component', require('./components/ExampleComponent.vue').default ); /** * Next, we will create a fresh Vue application instance and attach it to * the page. Then, you may begin adding components to this application * or customize the JavaScript scaffolding to fit your unique needs. */ const app = new Vue({ el: '#app' });
test.js
// まだ何も記入していないけどtest.blade.php関連のJavaScriptはここに書く予定
やっていること
npm install
npm run watch
追記1:今の状態
エラーも何も表示されておらず、真っ白な画面になっています。
<h1>テスト</h1>をいれると表示されるので、ルーティング等の問題はないです。動かないだけでは状況がわかりません。
発生している状況を具体的に記載してください。
回答1件
あなたの回答
tips
プレビュー