国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

vue3 + vite + ts + element-ui搭建后臺(tái)管理框架

這篇具有很好參考價(jià)值的文章主要介紹了vue3 + vite + ts + element-ui搭建后臺(tái)管理框架。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

1、創(chuàng)建vue3項(xiàng)目搭建


vue3官網(wǎng) vue3官網(wǎng)
vite vite官網(wǎng)連接

npm 安裝

// 創(chuàng)建項(xiàng)目
npm create vite@latest
? Project name: vue3_vite_project // 輸入項(xiàng)目名稱(chēng)

vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui
vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui
vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui
vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui

按照提示輸出即可!

2、安裝less、scss

vite 中使用 less 或 scss
安裝后在style 中設(shè)置對(duì)應(yīng)的 scss 或 less,推薦scss編譯

安裝less依賴(lài)

npm add -D less

安裝sass依賴(lài)

npm add -D sass

3、vite自動(dòng)導(dǎo)入語(yǔ)法插件

推薦使用插件,vite.config.js配置;
unplugin-vue-components // 自動(dòng)導(dǎo)入vue中hook reactive ref等AIP;
unplugin-auto-import // 自動(dòng)導(dǎo)入ui-組件 比如說(shuō)ant-design-vue element-plus等;

npm 使用
npm install -D unplugin-vue-components unplugin-auto-import

無(wú)需引入直接訪問(wèn)
vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui

vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui

vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// 自動(dòng)導(dǎo)入vue中hook reactive ref等
import AutoImport from "unplugin-auto-import/vite"
//自動(dòng)導(dǎo)入ui-組件 比如說(shuō)ant-design-vue  element-plus等
import Components from 'unplugin-vue-components/vite';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      //安裝兩行后你會(huì)發(fā)現(xiàn)在組件中不用再導(dǎo)入ref,reactive等
			imports: ['vue', 'vue-router'],
      //存放的位置
      dts: "src/auto-import.d.ts",
    }),
    Components({
      // 引入組件的,包括自定義組件
      // 存放的位置
      // dts: "src/components.d.ts"
    })
  ],
})

4、安裝router

vue-router官網(wǎng) vue-router官網(wǎng)

npm 安裝

npm install vue-router@4

安裝成功后在main.ts 引入 router
使用ts出現(xiàn)找不到模塊的問(wèn)題!

vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui

這個(gè)時(shí)候我們需要找到文件根目錄中的vite-env.d.ts文件中加入幾行代碼!

vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui
vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui

// 在文件中加上
declare module '*.vue' {
   import type { DefineComponent } from 'vue'
   const component: DefineComponent<{}, {}, any>
   export default component
}
// 或者
declare module '*.vue' {
   import type { DefineComponent } from 'vue'
   const component: ComponentOptions | ComponentOptions['setup']
   export default component
}

5、安裝pinia

vue3+ts使用pinia更好用,vuex使用ts沒(méi)有pinia優(yōu)雅
pinia 官網(wǎng) pinia官網(wǎng)

npm 安裝

npm install pinia

vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui
vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui

6、搭建后臺(tái)系統(tǒng)–基本配置layout頁(yè)面的搭建

1、下載element-ui-plus npm install element-plus --save
下載element icon 這個(gè)路由左側(cè)的icon會(huì)用到 npm install @element-plus/icons-vue
2、封裝公共js方法
3、將公共js掛載全局
4、引入element-ui
5、搭建菜單組件

1、element-ui-plus的使用
2、封裝公共js方法
vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui

3、將公共js掛載全局

這里需要注意的是,使用app.config.globalProperties有一些坑,我們?nèi)绾谓鉀Q遺留的問(wèn)題,請(qǐng)看下面示例:

解決方案1:

// 這里要注意 getCurrentInstance 模塊導(dǎo)入
  import { reactive, getCurrentInstance } from 'vue';
const { appContext } = getCurrentInstance();
const globalProxy = appContext.config.globalProperties;
console.log(appContext,'globalProxy')
// 通過(guò)appContext.config.globalProperties調(diào)用獲取
// 這樣使用 即使打包發(fā)布也不會(huì)出現(xiàn)問(wèn)題

解決方案2:

const { proxy } = getCurrentInstance()
console.log(proxy.$utlis.getHint(),'首頁(yè)')
console.log(proxy,'proxy')
// 獲取掛載在全局的方法
// 這樣使用 即使打包發(fā)布也不會(huì)出現(xiàn)問(wèn)題

vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui
vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui
vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui

** 4、引入element-ui**

vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui
vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui
5、搭建菜單組件

vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui
vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui
vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui
vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui
vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui
最后展示一下搭建的成品模塊:

vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui
vue3 + vite + ts + element-ui搭建后臺(tái)管理框架,vue,vue.js,javascript,nginx,前端,ui

到這里框架搭建已經(jīng)完成

預(yù)覽項(xiàng)目:預(yù)覽項(xiàng)目


總結(jié):

前端路上 | 所知甚少,唯善學(xué)。
各位小伙伴有什么疑問(wèn),歡迎留言探討。

— 關(guān)注我:前端路上不迷路 —文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-551700.html




到了這里,關(guān)于vue3 + vite + ts + element-ui搭建后臺(tái)管理框架的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶(hù)投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Vue3+Vite+Pinia+Naive后臺(tái)管理系統(tǒng)搭建之四:Naive UI 組件庫(kù)的安裝和使用

    Vue3+Vite+Pinia+Naive后臺(tái)管理系統(tǒng)搭建之四:Naive UI 組件庫(kù)的安裝和使用

    前言 如果對(duì) vue3 的語(yǔ)法不熟悉的,可以移步?Vue3.0 基礎(chǔ)入門(mén)Vue3.0 基礎(chǔ)入門(mén)快速入門(mén)。 UI 組件請(qǐng)參考官網(wǎng):Naive Ui 官網(wǎng) 為什么選擇 naive ui 不繼續(xù)用 element ui,因?yàn)橛却蟠笸扑],可以嘗試下,而且 naive ui 更貼近 vue3 的語(yǔ)法,當(dāng)然易上手還是element ui 好一點(diǎn)。 github 開(kāi)源庫(kù):Vue

    2024年02月07日
    瀏覽(128)
  • 【vue3-element-admin 】基于 Vue3 + Vite4 + TypeScript + Element-Plus 從0到1搭建后臺(tái)管理系統(tǒng)(前后端開(kāi)源@有來(lái)開(kāi)源組織)

    【vue3-element-admin 】基于 Vue3 + Vite4 + TypeScript + Element-Plus 從0到1搭建后臺(tái)管理系統(tǒng)(前后端開(kāi)源@有來(lái)開(kāi)源組織)

    vue3-element-admin 是基于 vue-element-admin 升級(jí)的 Vue3 + Element Plus 版本的后臺(tái)管理前端解決方案,技術(shù)棧為 Vue3 + Vite4 + TypeScript + Element Plus + Pinia + Vue Router 等當(dāng)前主流框架。 相較于其他管理前端框架,vue3-element-admin 的優(yōu)勢(shì)在于 一有一無(wú) ( 有 配套后端、 無(wú) 復(fù)雜封裝): 配套完整 J

    2023年04月21日
    瀏覽(97)
  • Vue3+element-ui + TS封裝全局分頁(yè)組件

    本文介紹了如何使用Vue3、element-ui和TypeScript封裝一個(gè)全局分頁(yè)組件。 在開(kāi)始之前,你需要安裝以下環(huán)境: Vue3 element-ui TypeScript 這個(gè)分頁(yè)組件提供以下功能: 支持自定義每頁(yè)顯示條數(shù) 支持自定義跳轉(zhuǎn)到指定頁(yè)碼 支持顯示總頁(yè)數(shù)和總條數(shù) 支持自定義樣式 分頁(yè)組件結(jié)構(gòu) 分頁(yè)組

    2024年02月12日
    瀏覽(24)
  • 【vue3-element-admin 】基于 Vue3 + Vite4 + TypeScript5+ Element-Plus 從0到1搭建企業(yè)級(jí)后臺(tái)管理系統(tǒng)(前后端開(kāi)源)

    【vue3-element-admin 】基于 Vue3 + Vite4 + TypeScript5+ Element-Plus 從0到1搭建企業(yè)級(jí)后臺(tái)管理系統(tǒng)(前后端開(kāi)源)

    vue3-element-admin 是基于 vue-element-admin 升級(jí)的 Vue3 + Element Plus 版本的后臺(tái)管理前端解決方案,技術(shù)棧為 Vue3 + Vite4 + TypeScript + Element Plus + Pinia + Vue Router 等當(dāng)前主流框架。 相較于其他管理前端框架,vue3-element-admin 的優(yōu)勢(shì)在于 一有一無(wú) (有配套后端、無(wú)復(fù)雜封裝): 配套完整 Java 后

    2024年02月07日
    瀏覽(98)
  • 使用 Vite + Vue3 + Element-Plus + Pinia + Ts 搭建 Vue3 項(xiàng)目

    使用 Vite + Vue3 + Element-Plus + Pinia + Ts 搭建 Vue3 項(xiàng)目

    Vite 需要 Node.js 版本 14.18+,16+。然而,有些模板需要依賴(lài)更高的 Node 版本才能正常運(yùn)行,當(dāng)你的包管理器發(fā)出警告時(shí),請(qǐng)注意升級(jí)你的 Node 版本。 首先 npm 輸入: Project name :項(xiàng)目名稱(chēng) Select a framework :選擇一個(gè)框架 Select a variant :選擇 ts 或者 js 輸入項(xiàng)目名稱(chēng)后選擇 vue 選擇

    2024年02月09日
    瀏覽(26)
  • 【vue后臺(tái)管理系統(tǒng)】基于Vue+Element-UI+ECharts開(kāi)發(fā)通用管理后臺(tái)(中)

    【vue后臺(tái)管理系統(tǒng)】基于Vue+Element-UI+ECharts開(kāi)發(fā)通用管理后臺(tái)(中)

    點(diǎn)擊菜單圖標(biāo)之前: 點(diǎn)擊菜單圖標(biāo)之后: 首先我們要知道菜單欄的收縮,由el-menu的collapse屬性控制: 我們通過(guò)分析可以知道: 菜單按鈕的點(diǎn)擊是在CommonHeader.vue組件中,而我們修改的collapse屬性卻在CommonAside.vue中,這是兩個(gè)不同的組件。很明顯這涉及到了組件間的通信問(wèn)題,

    2024年02月03日
    瀏覽(62)
  • vue3 vite直接創(chuàng)建項(xiàng)目 添加 element-ui 按需引入和全部引入

    vue3 vite直接創(chuàng)建項(xiàng)目 添加 element-ui 按需引入和全部引入

    ?創(chuàng)建home 工程 yran dev就可以看到一個(gè)網(wǎng)址 點(diǎn)進(jìn)去就可以看到效果了 添加element-ui 之前的main.js 修改后的 element-plus 在vue3中的按需引入。要比2簡(jiǎn)介很多 。自動(dòng)導(dǎo)入也是推薦的一種寫(xiě)法 我們注釋掉全局引用 ?然后改為按需引入 源文件 ?修改后 首先安裝兩款插件 修改后

    2024年02月17日
    瀏覽(28)
  • Vue+Element-UI搭建admin-shiro-ui后臺(tái)頁(yè)面

    Vue+Element-UI搭建admin-shiro-ui后臺(tái)頁(yè)面

    后端代碼:https://blog.csdn.net/qq_45660133/article/details/128498518 官網(wǎng)下載地址 http://nodejs.cn/download,如圖所示: 安裝 Node.js 淘寶鏡像加速器( npm ) 安裝 vue-cli 安裝Webpack: js打包即壓縮(可以忽略) 根據(jù)下面圖片選擇配置:空格是選擇,回車(chē)是確認(rèn)??! 在main.js 里面引用element-ui 組件 創(chuàng)

    2024年01月22日
    瀏覽(26)
  • Vue2+element-ui后臺(tái)管理系統(tǒng)(靜態(tài)頁(yè)面)

    Vue2+element-ui后臺(tái)管理系統(tǒng)(靜態(tài)頁(yè)面)

    node:https://nodejs.org/en/ git:https://git-scm.com/ vue:https://v2.cn.vuejs.org/v2/guide/installation.html element-ui:https://element.eleme.cn/#/zh-CN/component/installation 項(xiàng)目所需:https://pan.baidu.com/s/1ua0jp9YCtPH6slE49HDUBw 提取碼:kkkk 在node和vue都調(diào)試、配置好的情況下使用vscode 在終端中輸入命令 npm i -g @vue

    2024年02月06日
    瀏覽(43)
  • vue3 + vite自定義封裝vue + element-ui 表格組件,發(fā)布到npm包的全過(guò)程。

    vue3 + vite自定義封裝vue + element-ui 表格組件,發(fā)布到npm包的全過(guò)程。

    當(dāng)我們項(xiàng)目中用到的表格太多的話(huà),就會(huì)導(dǎo)致我們的代碼量一直增加,所以我們要封裝一個(gè)公共得組件,通過(guò)傳參引入來(lái)使用,下面這篇文章主要給大家介紹了關(guān)于vue3+vite自定義封裝vue組件發(fā)布到npm包的相關(guān)資料,需要的朋友可以參考下。 提示我們要安裝 create-vite@4.1.0 得依賴(lài)

    2024年02月02日
    瀏覽(26)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包