다음 튜토리얼 칼럼에서는 laravel8.0 + vue 설치에 대해 소개하겠습니다. 필요한 친구들에게 도움이 되길 바랍니다!
composer create-project --prefer-dist laravel/laravel fl_app composer install php artisan key:generate
yum install wget wget https://nodejs.org/dist/v12.18.3/node-v12.18.3-linux-x64.tar.xz#得到 一个包 node-v12.18.3-linux-x64.tar xz -d node-v12.18.3-linux-x64.tar.xz#得到一个目录 node-v12.18.3-linux-x64 tar -xvf node-v12.18.3-linux-x64.tar
切换到node bin目录 一共有三个文件 node npm npx src]# cd node-v12.18.3-linux-x64/bin/[root@VM-0-4-centos bin]# ll total 47508-rwxr-xr-x 1 work work 48646656 Jul 22 23:00 node lrwxrwxrwx 1 work work 38 Jul 22 23:00 npm -> ../lib/node_modules/npm/bin/npm-cli.js lrwxrwxrwx 1 work work 38 Jul 22 23:00 npx -> ../lib/node_modules/npm/bin/npx-cli.js[root@VM-0-4-centos bin]# 执行命令查看 node 版本 # ./node -v v12.18.3[root@VM-0-4-centos bin]# 截止目前为止表示node 已经可用了, 下一步是要让 node 命令全局可用
我的node 放在 /usr/local/src 目录下 ln -s /usr/local/src/node-v12.18.3-linux-x64/bin/node /usr/bin/node ln -s /usr/local/src/node-v12.18.3-linux-x64/bin/npm /usr/bin/npm ln -s /usr/local/src/node-v12.18.3-linux-x64/bin/npx /usr/bin/npx 任意目录 任意用户 执行:[root@VM-0-4-centos ~]# node -v v12.18.3[huipeng@VM-0-4-centos ~]$ node -v v12.18.3表示完成
npm install npm audit fix npm audit fix npm audit fix --force npm audit npm audit npm install
<!DOCTYPE html> <html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Laravel</title> <!--1、 引入支持 Bootstrap 的 CSS 样式文件 --> <link href="{{ asset('css/app.css') }}" rel="stylesheet"> </head> <body> <div id="app"> <div> <!-- 3、使用组件 --> <example-component></example-component> </div> </div> <!-- 2、引入支持Vue框架和Vue组件的app.js文件 --> <script src="{{ asset('js/app.js') }}"></script> </body> </html>
/** * First we will load all of this project's JavaScript dependencies which * includes Vue and other libraries. It is a great starting point when * building robust, powerful web applications using Vue and Laravel. */ require('./bootstrap'); window.Vue = require('vue').default; /** * The following block of code may be used to automatically register your * Vue components. It will recursively scan this directory for the Vue * components and automatically register them with their "basename". * * Eg. ./components/ExampleComponent.vue -> <example-component></example-component> */ // const files = require.context('./', true, /\.vue$/i) // files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default)) Vue.component('example-component', require('./components/ExampleComponent.vue').default); //Vue.component('example-component', require('./components/DemoComponent.vue').default); /** * Next, we will create a fresh Vue application instance and attach it to * the page. Then, you may begin adding components to this application * or customize the JavaScript scaffolding to fit your unique needs. */ const app = new Vue({ el: '#app', });
npm run dev
실시간 컴파일
npm run dev
를 다시 실행해야 합니다. 이는 매우 번거로운 작업입니다. npm run watch
명령을 사용하여 프런트엔드 리소스를 컴파일할 수 있습니다. 변경될 때마다 자동으로 다시 컴파일됩니다
npm run dev
,这样非常麻烦;
可以使用npm run watch
관련 권장 사항:
위 내용은 laravel8.0 + vue 설치 방법에 대한 자세한 설명의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!