分享laravel8+vue3.0+element-plus搭建方法

                                                       

下面由laravel教程栏目给大家介绍分享laravel8+vue3.0+element-plus搭建方法 ,希望对需要的朋友有所帮助!

分享laravel8+vue3.0+element-plus搭建方法

前言

前几天突然发现出了 vue3.0 ,刚好闲来无事搭个试试。

开始

创建 laravel8 项目

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

laravel new laravel8

安装 laravel/ui

composer require laravel/ui

根目录下运行

php artisan ui vue

修改 package.json 文件

"devDependencies": {      "@vue/compiler-sfc": "^3.0.7",      "axios": "^0.21",      "bootstrap": "^4.0.0",      "jquery": "^3.2",      "laravel-mix": "^6.0.6",      "lodash": "^4.17.19",      "popper.js": "^1.12",      "postcss": "^8.1.14",      "resolve-url-loader": "^3.1.2",      "sass": "^1.20.1",      "sass-loader": "^8.0.0",      "vue": "^3.0.7",      "vue-loader": "^16.1.0",      "vue-template-compiler": "^2.6.10"  },  "dependencies": {      "element-plus": "^1.0.2-beta.35",      "vue-router": "^4.0.5"  }

修改 app.js 文件

require('./bootstrap');window.Vue = require('vue');window.VueRouter = require('vue-router');import routes from "./router"import axios from "axios"import ElementPlus from 'element-plus'const router = VueRouter.createRouter({  history: VueRouter.createWebHashHistory(),  routes,})import RootComponent from "./components/layouts/App"const app = Vue.createApp(RootComponent)app.config.globalProperties.$http=axiosapp.use(router)  .use(ElementPlus);app.mount('#app')

新建 router.js

import Home from "./components/layouts/Home"export default [  {path:'/',component: Home},]

新建 App.vue (element-plus 官方文档例子)

        Header            Footer  export default {}.el-header, .el-footer {  background-color: #B3C0D1;  color: #333;  text-align: center;  line-height: 60px;}.el-aside {  background-color: #D3DCE6;  color: #333;  text-align: center;  line-height: 200px;}.el-main {  background-color: #E9EEF3;  color: #333;  text-align: center;  line-height: 160px;}body > .el-container {  margin-bottom: 40px;}.el-container:nth-child(5) .el-aside,.el-container:nth-child(6) .el-aside {  line-height: 260px;}.el-container:nth-child(7) .el-aside {  line-height: 320px;}

新建 Home.vue

  

home

export default { methods:{ cs(){ axios.post("../index").then(function (response){ console.log(response); }).catch(function (error){ console.log(error); }) } }, mounted() { this.cs(); }}

app.scss 引入 element-plus css文件

// Variables@import 'variables';// Bootstrap@import '~bootstrap/scss/bootstrap';// element-plus@import "~element-plus/lib/theme-chalk/index.css";

运行命令

npm install && npm run dev

效果图

laravel8+vue3.0 搭建

控制台输出为axios post 请求测试。

完毕!

以上就是分享laravel8+vue3.0+element-plus搭建方法的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/78434.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
如何成为帮扶产品经理人
上一篇 2025年11月15日 03:08:14
程序员如何说产品经理
下一篇 2025年11月15日 03:08:30

相关推荐

发表回复

登录后才能评论
关注微信