Home > Article > PHP Framework > Share a Laravel Mix compilation Vue pitfall record
The following tutorial column of Laravel will share with you a Laravel Mix compilation Vue pitfall record. I hope it will be helpful to friends in need!
Laravel Mix Compile Vue Pitfall Record
Environment:
// package "laravel-mix": "^6.0.6", // composer "laravel/framework": "^8.54" node version v15.14.0 npm version 7.7.6
First npm needs to install dependent vue, vue-loader, vue-template-compiler
Then open the webpack.mix.js file
// 将 mix.js('resources/js/app.js', 'public/js') // 修改为 mix.js('resources/js/app.js', 'public/js').vue()
Open/resources/js/app.js
import Vue from 'vue' // 必须引入 vue require('./bootstrap'); Vue.component('welcome-component', require('./components/WelcomeComponent.vue').default); // 组件后需要添加 .default 否则会报错 const app = new Vue({ el: '#app' });
Execution, about. The description of default can be found here https://github.com/vuejs/vue-loader/releases/tag/v13.0.0
npm run dev
That’s it. There are some changes after using Laravel-Mix 6, here Record it.
The above is the detailed content of Share a Laravel Mix compilation Vue pitfall record. For more information, please follow other related articles on the PHP Chinese website!