下面由laravel教程栏目给大家介绍laravel8.0 + vue 安装,希望对需要的朋友有所帮助!
创建项目laravel
composer create-project --prefer-dist laravel/laravel fl_appcomposer installphp artisan key:generate
安装node
yum install wgetwget 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]# lltotal 47508-rwxr-xr-x 1 work work 48646656 Jul 22 23:00 nodelrwxrwxrwx 1 work work 38 Jul 22 23:00 npm -> ../lib/node_modules/npm/bin/npm-cli.jslrwxrwxrwx 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 -vv12.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/nodeln -s /usr/local/src/node-v12.18.3-linux-x64/bin/npm /usr/bin/npmln -s /usr/local/src/node-v12.18.3-linux-x64/bin/npx /usr/bin/npx任意目录 任意用户 执行:[root@VM-0-4-centos ~]# node -vv12.18.3[huipeng@VM-0-4-centos ~]$ node -vv12.18.3表示完成
npm installnpm audit fixnpm audit fix npm audit fix --force npm auditnpm auditnpm install
改造laravel欢迎界面视图 resources/views/welcome.blade.php
getLocale()) }}">Laravel
安装完成后,Vue组件和JS文件在resources/js目录下;
入口文件resources/js/app.js文件
/** * 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 -> */// 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
实时编译
现在的情况是,每改动一次Vue组件就要重新执行npm run dev,这样非常麻烦;
可以使用npm run watch命令编译前端资源,每改动一次就会自动进行重新编译
立即学习“前端免费学习笔记(深入)”;
相关推荐:最新的五个Laravel视频教程
以上就是laravel8.0 + vue 安装方法详解的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/77811.html
微信扫一扫
支付宝扫一扫