在Laravel8裝了Vue3,但Laravel的Blade始終抓不到Vue的Data,請問邦友們,還有什麼細節是未注意到的嗎?
package.json
"devDependencies": {
"vue-loader": "^16.8.3"
},
"dependencies": {
"vue": "^3.2.37",
"vue-router": "^4.0.16"
},
resources/js/vue.js
window.Vue=require('vue');
webpack.mix.js
mix.js('resources/js/vue.js','public/js');
show.blade.php
<head>
<script src="js/vue.js"></script>
</head>
<body>
<span id="msg">
@{{ message }}
</span>
<script>
new Vue({
el: '#msg',
data: {
message: 'Lorem ipsum dolor sit amet consectetur.',
}
});
</script>
</body>
routes/web.php
Route::get('/vue', function (){
return view('show');
});
畫面輸出的結果
{{ message }}