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

rouyi-vue-pro+vue3+vite4+Element Plus項目中使用生成Vue2+Element UI標準模板

這篇具有很好參考價值的文章主要介紹了rouyi-vue-pro+vue3+vite4+Element Plus項目中使用生成Vue2+Element UI標準模板。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

運行一個pro-vue3的前端項目,以及后端服務

在基礎設施-代碼生成模塊中選擇某張數(shù)據(jù)庫表導入,并編輯生成信息,前端類型:Vue2+Element UI標準模板

在vue3項目中創(chuàng)建一個vue文件

<template>
</template>

<script>
// import {create} from '@/api/test'

export default{
  created(){
    create().then(res => {
      console.log(res);
    })
  }
}
</script>

1.4 src\api\test.js

import request from '@/utils/request'

// 創(chuàng)建藥品
export function create(data) {
  return request({
    url: '/drug//create',
    method: 'post',
    data: data
  })
}

Vue2+Element UI標準模板生成的前端封裝好的request請求接口對象

1.5 報錯

09:47:36 [vite] hmr update /src/views/tb/drug/index.vue
Failed to load url /src/utils/request (resolved id: C:/Users/lxz/Desktop/project/drug-system/ruoyi-vue-pro-drug/yudao-ui-admin-vue3/src/utils/request) in C:/Users/lxz/Desktop/project/drug-system/ruoyi-vue-pro-drug/yudao-ui-admin-vue3/src/api/test.js. Does the file exist?

問題:在 更新的/src/views/tb/drug/index.vue 文件中,沒有找到 /src/utils/request 這個文件

解決辦法: 從vue2項目中將/src/utils/request.js 這個文件復制到vue3項目的對應文件夾下

1.6 報錯

09:44:01 [vite] Internal server error: Failed to resolve import "element-ui" from "src\utils\request.js". Does the file exist?
  Plugin: vite:import-analysis
  File: C:/Users/lxz/Desktop/project/drug-system/ruoyi-vue-pro-drug/yudao-ui-admin-vue3/src/utils/request.js:2:51
  1  |  import axios from 'axios'
  2  |  import {Message, MessageBox, Notification} from 'element-ui'
     |                                                    ^
  3  |  import store from '@/store'
  4  |  import {getAccessToken, getRefreshToken, getTenantId, setToken} from '@/utils/auth'
  • import axios from ‘axios’

    這個是vue2項目中直接引入使用的外部axios依賴

     "dependencies": {
        "@babel/parser": "7.18.4",
        "@riophae/vue-treeselect": "0.4.0",
        "axios": "0.27.2",
         ...
    

    在vue3項目中沒有直接使用這個依賴,而是對axios進行了擴展

      "dependencies": {
        "@element-plus/icons-vue": "^2.1.0",
        "@form-create/designer": "^3.1.3",
        "@form-create/element-ui": "^3.1.24",
        "@iconify/iconify": "^3.1.1",
        "@videojs-player/vue": "^1.0.0",
        "@vueuse/core": "^10.6.1",
        "@wangeditor/editor": "^5.1.23",
        "@wangeditor/editor-for-vue": "^5.1.10",
        "@zxcvbn-ts/core": "^3.0.4",
        "animate.css": "^4.1.1",
        "axios": "^1.6.1",
    

    vue3項目中的axios封裝鏈:

    1. 從vue3項目的src/system/area/index.ts文件中封裝的request對象進行向底層追溯

      import request from '@/config/axios'
      
      // 獲得地區(qū)樹
      export const getAreaTree = async () => {
        return await request.get({ url: '/system/area/tree' })
      }
      
      // 獲得 IP 對應的地區(qū)名
      export const getAreaByIp = async (ip: string) => {
        return await request.get({ url: '/system/area/get-by-ip?ip=' + ip })
      }
      
    2. 進入 src/config/axios/index.ts文件中

      import { service } from './service'
      
      import { config } from './config'
      
      const { default_headers } = config
      
      const request = (option: any) => {
        const { url, method, params, data, headersType, responseType, ...config } = option
        return service({
          url: url,
          method,
          params,
          data,
          ...config,
          responseType: responseType,
          headers: {
            'Content-Type': headersType || default_headers
          }
        })
      }
      
      export default {
        get: async <T = any>(option: any) => {
          const res = await request({ method: 'GET', ...option })
          return res.data as unknown as T
        },
        post: async <T = any>(option: any) => {
          const res = await request({ method: 'POST', ...option })
          return res.data as unknown as T
        },
        postOriginal: async (option: any) => {
          const res = await request({ method: 'POST', ...option })
          return res
        },
        delete: async <T = any>(option: any) => {
          const res = await request({ method: 'DELETE', ...option })
          return res.data as unknown as T
        },
        put: async <T = any>(option: any) => {
          const res = await request({ method: 'PUT', ...option })
          return res.data as unknown as T
        },
        download: async <T = any>(option: any) => {
          const res = await request({ method: 'GET', responseType: 'blob', ...option })
          return res as unknown as Promise<T>
        },
        upload: async <T = any>(option: any) => {
          option.headersType = 'multipart/form-data'
          const res = await request({ method: 'POST', ...option })
          return res as unknown as Promise<T>
        }
      }
      

      封裝http請求對象,并導出get、post、postOriginal、delete、put、download、upload等公共方法

    3. 進入 ./config文件中

      const config: {
        base_url: string
        result_code: number | string
        default_headers: AxiosHeaders
        request_timeout: number
      } = {
        /**
         * api請求基礎路徑
         */
        base_url: import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL,
        /**
         * 接口成功返回狀態(tài)碼
         */
        result_code: 200,
      
        /**
         * 接口請求超時時間
         */
        request_timeout: 30000,
      
        /**
         * 默認接口請求類型
         * 可選值:application/x-www-form-urlencoded multipart/form-data
         */
        default_headers: 'application/json'
      }
      
      export { config }
      

      封裝了http請求的請求基礎路徑、返回結果狀態(tài)碼、請求頭、請求超時時間等配置信息

    4. 進入./service文件中

      import axios, {
        AxiosError,
        AxiosInstance,
        AxiosRequestHeaders,
        AxiosResponse,
        InternalAxiosRequestConfig
      } from 'axios'
      

? 在這里可以看到vue2項目中使用的axios對象,此時,vue3項目中使用的axios版本和vue2項目中使用的版本不一致可能會存在隱患

  • import {Message, MessageBox, Notification} from ‘element-ui’

? 此處引用了element-ui的依賴,在vue3項目中已經棄用了element-ui而是采用Element Plus

? vue3項目中的依賴

    "element-plus": "2.4.2",

? vue2項目中依賴

  "element-ui": "2.15.12",

? 需要對vue2項目中的request.js中使用的element-ui進行改造成element-plus中的組件!

  • import store from ‘@/store’

    在vue2項目中使用的vuex來做狀態(tài)管理的,在vue3項目中是沒有引入vuex依賴的

    在vue3項目中使用了vue-demi來解決這個問題嗎,那么我們在保證vue-demi可用的前提下可以不用考慮這個問題!

  • import {getAccessToken, getRefreshToken, getTenantId, setToken} from ‘@/utils/auth’

    這個在vue3項目中已經兼容了并且做了局部功能升級,在vue2版本的項目中沒有對AccessTokenKey,RefreshTokenKey加入到瀏覽器本地存儲中,在vue3項目中引入了web-storage-cache來做本地存儲

       "web-storage-cache": "^1.1.1",
    

可以在使用生成Vue2+Element UI標準模板的api.js文件中使用vue3項目封裝的ts文件中對象

// import request from '@/utils/request'
// 這個是vue3項目中使用.ts文件封裝的http請求對象
import request from '@/config/axios'

// 創(chuàng)建藥品
export function create(data) {
  return request({
    url: '/drug//create',
    method: 'post',
    data: data
  })
}

// 獲得地區(qū)樹 這個是ts文件封裝的http請求對象的使用方法
export const getAreaTree = async () => {
  return await request.get({ url: '/system/area/tree' })
}

這個文件是src\api\test.js

<template>
111
</template>

<script>
import {getAreaTree} from '@/api/test'

export default{
  created(){
    getAreaTree().then(res => {
      console.log(res);
    })
  }
}
</script>

這是測試的vue文件打印到請求的數(shù)據(jù)
hmr update /src/views/personnelevaluation/evaluatebatch.vue (x2),前端,ruoyi,vue文章來源地址http://www.zghlxwxcb.cn/news/detail-771678.html

根據(jù)vue2模板生成的vue頁面代碼無法直接在vue3項目中使用,需要逐個修改生成的.vue文件中的代碼

  Plugin: vite-plugin-eslint
  File: C:/Users/lxz/Desktop/project/drug-system/ruoyi-vue-pro-drug/yudao-ui-admin-vue3/src/views/tb/drug/index.vue
12:13:26 [vite] Internal server error:
C:\Users\lxz\Desktop\project\drug-system\ruoyi-vue-pro-drug\yudao-ui-admin-vue3\src\views\tb\drug\index.vue
    7:89   error    '.native' modifier on 'v-on' directive is deprecated                                  vue/no-deprecated-v-on-native-modifier
   10:99   error    '.native' modifier on 'v-on' directive is deprecated                                  vue/no-deprecated-v-on-native-modifier
   13:95   error    '.native' modifier on 'v-on' directive is deprecated                                  vue/no-deprecated-v-on-native-modifier
   16:92   error    '.native' modifier on 'v-on' directive is deprecated                                  vue/no-deprecated-v-on-native-modifier
   19:100  error    '.native' modifier on 'v-on' directive is deprecated                                  vue/no-deprecated-v-on-native-modifier
   22:96   error    '.native' modifier on 'v-on' directive is deprecated                                  vue/no-deprecated-v-on-native-modifier
   25:25   warning  Expected a linebreak before this attribute                                            vue/first-attribute-linebreak

到了這里,關于rouyi-vue-pro+vue3+vite4+Element Plus項目中使用生成Vue2+Element UI標準模板的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!

本文來自互聯(lián)網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉載,請注明出處: 如若內容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • Vue3.2 + TypeScript + Pinia + Vite4 + Element-Plus + 微前端(qiankun) 后臺管理系統(tǒng)模板(已開源---顯示項目頁面截圖)

    Vue3.2 + TypeScript + Pinia + Vite4 + Element-Plus + 微前端(qiankun) 后臺管理系統(tǒng)模板(已開源---顯示項目頁面截圖)

    Wocwin-Admin,是基于 Vue3.2、TypeScript、Vite、Pinia、Element-Plus、Qiankun(微前端) 開源的一套后臺管理模板;同時集成了微前端 qiankun也可以當做一個子應用。項目中組件頁面使用了Element-plus 二次封裝 t-ui-plus 組件,目前已新增fastmock接口。 Link:https://wocwin.github.io/wocwin-admin/ 賬號:

    2024年02月08日
    瀏覽(40)
  • Vue3.3 + Vite4.3 + TypeScript5+ Element-Plus:從零到一構建企業(yè)級后臺管理系統(tǒng)(前后端開源)

    Vue3.3 + Vite4.3 + TypeScript5+ Element-Plus:從零到一構建企業(yè)級后臺管理系統(tǒng)(前后端開源)

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

    2024年02月09日
    瀏覽(96)
  • 基于uniapp+vite4+vue3搭建跨端項目|uni-app+uview-plus模板

    基于uniapp+vite4+vue3搭建跨端項目|uni-app+uview-plus模板

    最近得空學習了下uniapp結合vue3搭建跨端項目。之前也有使用uniapp開發(fā)過幾款聊天/仿抖音/后臺管理等項目,但都是基于vue2開發(fā)。隨著vite.js破局出圈,越來越多的項目偏向于vue3開發(fā),就想著uniapp搭配vite4.x構建項目效果會如何?經過一番嘗試果然真香~ uniapp官網提供了? HBuild

    2024年02月09日
    瀏覽(95)
  • (小程序)基于uniapp+vite4+vue3搭建跨端項目|uni-app+uview-plus模板

    (小程序)基于uniapp+vite4+vue3搭建跨端項目|uni-app+uview-plus模板

    版本信息: 點擊編輯器的文件 新建 項目(快捷鍵Ctrl+N) 2.選擇uni-app項目,輸入項目名/路徑,選擇項目模板,勾選vue3版本,點擊創(chuàng)建,即可成功創(chuàng)建。 3.點擊編輯器的運行 運行到瀏覽器 選擇瀏覽器 當然也可以運行到手機或模擬器、運行到小程序工具。 到這里一個簡單的

    2024年02月16日
    瀏覽(97)
  • 于vue3+vite+element pro + pnpm開源項目

    于vue3+vite+element pro + pnpm開源項目

    河碼桌面是一個基于vue3+vite+element pro + pnpm 創(chuàng)建的monorepo項目,項目采用的是類操作系統(tǒng)的web界面,操作起來簡單又方便,符合用戶習慣,又沒有操作系統(tǒng)的復雜! 有兩個兩個分支,一個是web版本,一個是electron,只需要將分支切換到electron即可,下面有electron的效果圖。 web開

    2024年02月12日
    瀏覽(16)
  • 使用 Vite + Vue3 + Element-Plus + Pinia + Ts 搭建 Vue3 項目

    使用 Vite + Vue3 + Element-Plus + Pinia + Ts 搭建 Vue3 項目

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

    2024年02月09日
    瀏覽(27)
  • vue3+vite+element-plus創(chuàng)建項目,修改主題色

    vue3+vite+element-plus創(chuàng)建項目,修改主題色

    根據(jù)官方文檔安裝依賴 vite.config.js配置 新建一個文修改全局樣式的文件 在src下新建styles/element/index.scss文件,內容如下: @forward \\\'element-plus/theme-chalk/src/common/var.scss\\\' with ( ? ? $colors: ( ? ? ? ? \\\'primary\\\': ( ? ? ? ? ? ? //主色 ? ? ? ? ? ? \\\'base\\\':green ? ? ? ? ) ? ? ? ? //修改其他

    2024年02月10日
    瀏覽(26)
  • 若依(ruoyi)前端Vue3 Element Plus Vite版樣式修改

    若依(ruoyi)前端Vue3 Element Plus Vite版樣式修改

    位置: src/layout/components/Navbar.vue 類名: .navbar 這里主要是修改導航欄的背景色,在修改顏色值時,你可以使用其他十六進制顏色代碼,也可以嘗試使用RGB、RGBA或HSL等其他表示顏色的方式。這取決于你的設計需求和個人喜好。 這段主要是修改右側的圖標,隱藏、全屏等方法:

    2024年02月03日
    瀏覽(26)
  • 詳解Vite創(chuàng)建Vue3項目+vue-router+ts+vite+element-plus

    詳解Vite創(chuàng)建Vue3項目+vue-router+ts+vite+element-plus

    前言 在之前的文章中寫過“Vue3+TS+ElementPlus的安裝和使用教程【詳細講解】”,但那篇文章寫的是創(chuàng)建vue3的項目沒有使用到Vite構建工具進行創(chuàng)建還是使用的常規(guī)webpacket構建工具進行創(chuàng)建的。提到Vite和webpacket的時候我們可以簡單說一下。 Vite 和 Webpack 都是現(xiàn)代化的前端構建工

    2024年01月18日
    瀏覽(24)
  • Vue3+TS+Vite創(chuàng)建項目,并導入Element-plus和Sass

    Vue3+TS+Vite創(chuàng)建項目,并導入Element-plus和Sass

    1.桌面新建一個文件夾Vue3-app 打開編輯器導入文件夾,編輯器打開終端輸入或者命令行工具cd到項目目錄下輸入 npm init vue@latest 回車運行 這里我選擇了TS+Vite來開發(fā),并選擇安裝路由 2.cd到 vue-project目錄下 輸入 npm install 回車運行 3.安裝完成后 輸入 npm run dev 回車運行 瀏覽器打開

    2024年02月16日
    瀏覽(24)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

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

二維碼1

領取紅包

二維碼2

領紅包