請首先按照Laravel快速入門完成Laravel的基本了解和安裝。
然后在根目錄下的package.json文件中將vue的版本改成你希望使用的版本(Laravel 5.5 默認使用2.1.10),然后執行npm install.
也可以,直接npm install, 然后再運行npm install vue安裝最新的穩定版vue.
Laravel中默認有vue example files。
/js? ? ? ? ? ? ? ? ? ? ? ? ? 這個目錄js的源碼目錄,Vue的代碼都放在這里。
/js/components? ? ? 這個目錄下存放的是Vue單文件組件。
js/bootstrap.js? ? ? ? 所有的js依賴都寫在這個文件里。
js/app.js? ? ? ? ? ? ? ? ?這個文件是Vue的入口文件。
將welcome.blade.php內容改為:
并將app.js中
Vue.component('example-component',require('./components/ExampleComponent.vue'));
改為
Vue.component('example',require('./components/ExampleComponent.vue'));
(也可以只改welcome.blade.php中的example,我這是測試改了example后是否也可行)
命令行中執行npm run watch, 就會編譯css 和js到public中,然后打開瀏覽器可以看到如下頁面:
vue的使用沒有問題的話,
接下來安裝Element UI, 現在已經有2.0 alpha 版了。
npm i element-ui@next -S
。