###前提・実現したいこと
PHP(Laravel5.5)のサンプルコードを試しているのですが、
Vue.jsがうんともすんとも言わず困っています。
「npm run dev」でのコンパイルは成功しています。
以下のソースコードを動かすと、以下のようなエラーメッセージがでます。
さらに、bladeの方の記述を「@{{message}}」に変更してみると、
「{{message}}」という文字列がブラウザに表示され、
「this is ok」と表示されません。
###エラーメッセージ
"Use of undefined constant message - assumed 'message' (View: /Users/shoko/Develop/urbeaut/resources/views/register.blade.php)"
###該当のソースコード
resources/assets/js/app.js
(サンプルに「data:{message:"this is ok")}」を追加)
Javascript
1require('./bootstrap'); 2window.Vue = require('vue'); 3Vue.component('example-component', require('./components/ExampleComponent.vue')); 4 5const app = new Vue({ 6 el: '#app', 7 data: { 8 message:"this is ok" 9}
resources/views/register.blade.php
(新規作成のファイルです。)
HTML
1<div id="app">{{message}}</div>
routes/web.php
(既存ファイルに追加しています。)
PHP
1Route::get('/register', function() { 2 return view('register'); 3});
###参考URL
https://github.com/laravel/laravel
https://github.com/laravel/framework
(サンプルと完全一致するソースが見つからないので、代わりに参考URLを貼っています。)
以上、お時間ありましたら、どなたかよろしくお願いいたします。
回答4件
あなたの回答
tips
プレビュー