最新消息: 关于Git&GitHub 版本控制你了解多少?
您现在的位置是:群英 > 开发技术 > PHP语言 >
laravel8.0 vue 怎样快速安装?
PHP中文网发表于 2021-05-20 17:26 次浏览
下面由 群英网络给大家介绍laravel8.0 vue 安装,希望对需要的朋友有所帮助!

创建项目laravel

composer create-project --prefer-dist laravel/laravel fl_app

composer install

php artisan key:generate

安装node

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

改造laravel欢迎界面视图 resources/views/welcome.blade.php

<!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>

安装完成后,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 -> <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

实时编译

现在的情况是,每改动一次Vue组件就要重新执行npm run dev,这样非常麻烦;

可以使用npm run watch命令编译前端资源,每改动一次就会自动进行重新编译

相关推荐:最新的五个Laravel视频教程

以上就是laravel8.0 vue 安装方法详解的详细内容,更多请关注群英网络其它相关文章!

标签:laravel开发
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
上一篇:没有了
相关信息推荐
2021-09-15 18:27:44 关键词:laravel写法
摘要:今天给大家分享laravel优雅框架写法,新手在刚接触laravel框架就要注意写法的问题,对于laravel的一些写法要注意,养成好的习惯。对此,小编给大家整理了一些Laravel 不太建议的写法,大..
2021-09-15 18:27:29 关键词:laravel框架路由
摘要:laravel框架路由有多少种?在laravel框架中,常见的路由有post,get,put,patch,delete,options。接下来我们就来了解一下它们的写法以及要注意的问题。..
2021-09-15 18:27:20 关键词:laravel框架的优点
摘要:laravel框架的优点和主要功能是什么?对于laravel框架的优点有很多,例如功能多、开源项目多、测试方便和有强大的表单验证功能等等。这篇文章小编就给大家来详细的介绍一下laravel框架..
2021-09-15 18:27:04 关键词:laravel 辅助函数
摘要:今天给大家分享laravel中辅助函数optional()的内容,小编觉得optional()非常实用,因此分享给大家做个参考,下文有对optional()的应用场景及使用有详细介绍,感兴趣的朋友可以参考。..
2021-09-07 18:12:27 关键词:Laravel子查询
摘要:Laravel子查询语句怎么样使用?今天小编就给大家分享一篇Laravel子查询语句使用的实例,对大家学习Laravel子查询有一定的帮助,有需要的朋友可以参考,接下来跟随小编来看看吧。..