Php/laravel/laravel5/laravelmix/vue
提供: 初心者エンジニアの簡易メモ
vue動作確認
laravel5.4以上にデフォで入ってるvueのexampleコンポーネントを表示
~.blade.php
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>Hello Vue</title> <link rel="stylesheet" href="css/app.css"/> <script type="text/javascript"> window.Laravel = window.Laravel || {}; window.Laravel.csrfToken = "テンプレート:Csrf token()"; </script> </head> <body>
<example></example>
<script src="js/app.js"></script> </body> </html>
以下のように表示されれば成功 Example Component I'm an example component!
example.vue定義場所
resources/assets/js/app.js
Vue.component('example', require('./components/Example.vue'));
resources/assets/js/components/Example.vue
<template> <div class="container"> <div class="row"> <div class="col-md-8 col-md-offset-2"> <div class="panel panel-default"> <div class="panel-heading">Example Component</div> <div class="panel-body"> I'm an example component! </div> </div> </div> </div> </div> </template> <script> export default { mounted() { console.log('Component mounted.') } } </script>