Home > PHP Framework > Laravel > body text

Share a Laravel Mix compilation Vue pitfall record

藏色散人
Release: 2021-09-13 15:30:10
forward
2415 people have browsed it

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!

Share a Laravel Mix compilation Vue pitfall record

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
Copy after login

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()
Copy after login

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'
});
Copy after login

Execution, about. The description of default can be found here https://github.com/vuejs/vue-loader/releases/tag/v13.0.0

npm run dev
Copy after login

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!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template