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

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

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

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

Laravel 5

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

Q&A

解決済

1回答

860閲覧

laravel でVue.jsが動かない

hilhilyzyan

総合スコア19

Vue.js

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

Laravel 5

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

0グッド

0クリップ

投稿2019/01/11 14:16

編集2019/01/12 01:15

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>をいれると表示されるので、ルーティング等の問題はないです。

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

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

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

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

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

CHERRY

2019/01/11 21:48

動かないだけでは状況がわかりません。 発生している状況を具体的に記載してください。
guest

回答1

0

自己解決

特に何もしてないような気がするのですが、ちゃんと動くようになりました。
なんでだろう。

何かtypoミスをしてたかもしれません、cssとjsの読み込み部分をこれをコピペしたら、なおりました

<link href="{{ mix('css/app.css') }}" rel="stylesheet" type="text/css"> <script src="{{ mix('js/app.js') }}"></script>

投稿2019/01/12 01:52

hilhilyzyan

総合スコア19

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.51%

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

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

質問する

関連した質問