分享laravel8+vue3.0+element-plus搭建方法
前幾天突然發現出了 vue3.0 ,剛好閒來無事搭個試試。
開始
建立laravel8 專案composer create-project laravel/laravel laravel8 --prefer-dist
laravel new laravel8
安裝laravel/uicomposer require laravel/ui
登入後複製根目錄下執行php artisan ui vue
登入後複製
修改package.json 檔案composer require laravel/ui
php artisan ui vue
"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驗證系統的方法。

Laravel的工匠控制台可以自動化任務,例如生成代碼,運行遷移和調度。關鍵命令包括:控制器,遷移和DB:種子。可以為特定需求創建自定義命令,增強工作流效率。

文章討論了使用Laravel的路由來創建SEO友好的URL,涵蓋最佳實踐,規範的URL和SEO優化工具。WordCount:159

Django和Laravel都是全棧框架,Django適合Python開發者和復雜業務邏輯,Laravel適合PHP開發者和優雅語法。 1.Django基於Python,遵循“電池齊全”哲學,適合快速開發和高並發。 2.Laravel基於PHP,強調開發者體驗,適合小型到中型項目。

本文討論了使用Laravel中的數據庫交易來維持數據一致性,使用DB立面和雄辯模型的詳細方法,最佳實踐,異常處理以及用於監視和調試交易的工具。
