分享laravel8+vue3.0+element-plus搭建方法
下面由laravel教程栏目给大家介绍分享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=axios app.use(router) .use(ElementPlus);app.mount('#app')
登录后复制 - 新建 router.js
import Home from "./components/layouts/Home"export default [ {path:'/',component: Home},]
登录后复制 - 新建 App.vue (element-plus 官方文档例子)
<template> <el-container> <el-header>Header</el-header> <el-main><router-view></router-view></el-main> <el-footer>Footer</el-footer> </el-container></template><script>export default {}</script><style>.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;}</style>
登录后复制 - 新建 Home.vue
<template> <p>home</p></template><script>export default { methods:{ cs(){ axios.post("../index").then(function (response){ console.log(response); }).catch(function (error){ console.log(error); }) } }, mounted() { this.cs(); }}</script><style scoped></style>
登录后复制 - 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
登录后复制 - 效果图
控制台输出为axios post 请求测试。
完毕!
以上是分享laravel8+vue3.0+element-plus搭建方法的详细内容。更多信息请关注PHP中文网其他相关文章!

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

本文讨论了使用组件在Laravel中创建和自定义可重复使用的UI元素,从而为组织提供最佳实践并建议增强包装。

本文讨论了Laravel中的创建和使用自定义刀片指令以增强模板。它涵盖了定义指令,在模板中使用它们,并在大型项目中管理它们,强调了改进的代码可重复性和R等好处

本文讨论了Laravel中的创建和使用自定义验证规则,提供了定义和实施的步骤。它突出了诸如可重复性和特异性之类的好处,并提供了扩展Laravel验证系统的方法。

Laravel的工匠控制台可以自动化任务,例如生成代码,运行迁移和调度。关键命令包括:控制器,迁移和DB:种子。可以为特定需求创建自定义命令,增强工作流效率。

文章讨论了使用Laravel的路由来创建SEO友好的URL,涵盖最佳实践,规范的URL和SEO优化工具。WordCount:159

Django和Laravel都是全栈框架,Django适合Python开发者和复杂业务逻辑,Laravel适合PHP开发者和优雅语法。1.Django基于Python,遵循“电池齐全”哲学,适合快速开发和高并发。2.Laravel基于PHP,强调开发者体验,适合小型到中型项目。

本文讨论了使用Laravel中的数据库交易来维持数据一致性,使用DB立面和雄辩模型的详细方法,最佳实践,异常处理以及用于监视和调试交易的工具。

本文讨论了在Laravel中实施缓存以提高性能,使用缓存外观,缓存标签和原子操作涵盖配置。它还概述了缓存配置的最佳实践,并提出了用于缓存的数据类型
