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

vue3+vite+ts+elementplus創(chuàng)建項目

這篇具有很好參考價值的文章主要介紹了vue3+vite+ts+elementplus創(chuàng)建項目。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

# vue3+vite+ts+pinia 學習筆記

## 1、創(chuàng)建項目: npm init vite@latest

? ? 選擇: vue、ts

## 2、進入項目目錄后:npm install 安裝

## 3、運行項目: npm run dev

## 4、安裝常用插件:

? ? 1、安裝 npm install vue-router@latest 配置:在src目錄下新建router目錄,創(chuàng)建index.ts文件代碼如下: ? ? ?

```javascript 創(chuàng)建路由文件? ? ? ?

 import { createRouter, createWebHistory } from 'vue-router'

? ? ? ? ? ? ? ? import Layout from '@/views/layout/index.vue'

? ? ? ? ? ? ? ? import Login from '@/views/login/Login.vue'

? ? ? ? ? ? ? ? import Home from '@/views/home/Home.vue'

? ? ? ? ? ? ? ? // 懶加載

? ? ? ? ? ? ? ? const Product = ()=>import('@/views/product/Index.vue')

? ? ? ? ? ? ? ? const List = ()=>import('@/views/product/list/List.vue')

? ? ? ? ? ? ? ? const Category = ()=>import('@/views/product/category/Category.vue')



? ? ? ? ? ? ? ? const order = ()=>import('@/views/order/Index.vue')

? ? ? ? ? ? ? ? const order_List = ()=>import('@/views/order/list/List.vue')

? ? ? ? ? ? ? ? const order_Collect = ()=>import('@/views/order/collect/Collect.vue')



? ? ? ? ? ? ? ? const router = createRouter({

? ? ? ? ? ? ? ? history: createWebHistory(import.meta.env.BASE_URL),

? ? ? ? ? ? ? ? routes: [

? ? ? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? path:'/',

? ? ? ? ? ? ? ? ? ? name:'',

? ? ? ? ? ? ? ? ? ? component:Layout,

? ? ? ? ? ? ? ? ? ? children:[

? ? ? ? ? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? path:'/',

? ? ? ? ? ? ? ? ? ? ? ? name:'home',

? ? ? ? ? ? ? ? ? ? ? ? component:Home

? ? ? ? ? ? ? ? ? ? ? ? },

? ? ? ? ? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? path:'/product',

? ? ? ? ? ? ? ? ? ? ? ? name:'product',

? ? ? ? ? ? ? ? ? ? ? ? component:Product,

? ? ? ? ? ? ? ? ? ? ? ? children:[

? ? ? ? ? ? ? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? ? ? path:'list',

? ? ? ? ? ? ? ? ? ? ? ? ? ? name:'list',

? ? ? ? ? ? ? ? ? ? ? ? ? ? component:List

? ? ? ? ? ? ? ? ? ? ? ? ? ? },

? ? ? ? ? ? ? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? ? ? path:'category',

? ? ? ? ? ? ? ? ? ? ? ? ? ? name:'category',

? ? ? ? ? ? ? ? ? ? ? ? ? ? component:Category

? ? ? ? ? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ? ? ? ]

? ? ? ? ? ? ? ? ? ? ? ? },

? ? ? ? ? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? path:'/order',

? ? ? ? ? ? ? ? ? ? ? ? name:'order',

? ? ? ? ? ? ? ? ? ? ? ? component:order,

? ? ? ? ? ? ? ? ? ? ? ? children:[

? ? ? ? ? ? ? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? ? ? path:'order_list',

? ? ? ? ? ? ? ? ? ? ? ? ? ? name:'order_List',

? ? ? ? ? ? ? ? ? ? ? ? ? ? component:order_List

? ? ? ? ? ? ? ? ? ? ? ? ? ? },

? ? ? ? ? ? ? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? ? ? path:'order_collect',

? ? ? ? ? ? ? ? ? ? ? ? ? ? name:'order_collect',

? ? ? ? ? ? ? ? ? ? ? ? ? ? component:order_Collect

? ? ? ? ? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ? ? ? ]

? ? ? ? ? ? ? ? ? ? ? ? },

? ? ? ? ? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ? ? ]

? ? ? ? ? ? ? ? ? ? },{

? ? ? ? ? ? ? ? ? ? path:'/login',

? ? ? ? ? ? ? ? ? ? name:'login',

? ? ? ? ? ? ? ? ? ? component:Login

? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ]

? ? ? ? ? ? ? ? })



? ? ? ? ? ? ? ? export default router

? ? ? ?

```

```javascript 注冊路由組件? ?

注冊路由組件:在main.ts文件中注冊:

? ? import router from './router'

? ? app.use(router)

```

? ? 2、安裝 npm install pinia 配置:在src目錄下新建stores目錄,創(chuàng)建counter.ts文件代碼如下:

```javascript 創(chuàng)建倉庫文件? ?

import { ref, computed } from 'vue'

? ? import { defineStore } from 'pinia'



? ? export const useCounterStore = defineStore('counter', () => {

? ? const count = ref(0)

? ? const doubleCount = computed(() => count.value * 2)

? ? function increment() {

? ? ? ? count.value++

? ? }

? ? return { count, doubleCount, increment }

? ? })



? ? export const useUser = defineStore('user',()=>{

? ? const user = ref({

? ? ? ? name:'劉德華',

? ? ? ? age:64

? ? })

? ? return {user}

? ? })

```

```javascript 注冊路由組件? ?

import { createPinia } from 'pinia'

? ? const pinia = createPinia()

? ? app.use(pinia)

```

? ? 2、npm install element-plus --save

```javascript 完整導入 (推薦使用)? ?

import ElementPlus from 'element-plus'

? ? import 'element-plus/dist/index.css'

? ? app.use(ElementPlus)

```

```javascript 按需導入 (需要安裝插件:npm install -D unplugin-vue-components unplugin-auto-import) 在vite.config.ts中修改一下代碼? ?

 import { defineConfig } from 'vite'

? ? import AutoImport from 'unplugin-auto-import/vite'

? ? import Components from 'unplugin-vue-components/vite'

? ? import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'



? ? export default defineConfig({

? ? ? ? plugins: [

? ? ? ? ? ? vue(),

? ? ? ? ? ? // ...

? ? ? ? ? ? AutoImport({

? ? ? ? ? ? resolvers: [ElementPlusResolver()],

? ? ? ? ? ? }),

? ? ? ? ? ? Components({

? ? ? ? ? ? resolvers: [ElementPlusResolver()],

? ? ? ? ? ? }),

? ? ? ? ],

? ? })

? ?

```

```javascript element-plus圖標顯示? ?

 <script lang="ts" setup>

? ? ? ? import {Check,Delete,Edit,Message,Search,Star,} from '@element-plus/icons-vue'

? ? </script>

``` ?

? ? 3、npm i axios -S 直接安裝即可使用

? ? 5、npm i --save-dev @types/qs 直接安裝即可使用

? ? 6、npm i echarts -S

```javascript echarts按需導入使用教程

? ? 1、在src目錄下創(chuàng)建一個文件夾,命名為插件:plugins目錄,創(chuàng)建一個echarts.ts文件復制一下內容至文件:? ?

// 圖表

? ? import * as echarts from 'echarts/core';

? ? import {BarChart,LineChart,PieChart} from 'echarts/charts';

? ? import {TitleComponent,TooltipComponent,GridComponent,DatasetComponent,TransformComponent} from 'echarts/components';

? ? import { LabelLayout, UniversalTransition } from 'echarts/features';

? ? import { CanvasRenderer } from 'echarts/renderers';

? ? import type {BarSeriesOption, LineSeriesOption} from 'echarts/charts';

? ? import type {TitleComponentOption,TooltipComponentOption,GridComponentOption,DatasetComponentOption} from 'echarts/components';

? ? import type { ComposeOption, } from 'echarts/core';



? ? // 通過 ComposeOption 來組合出一個只有必須組件和圖表的 Option 類型

? ? type ECOption = ComposeOption<

? ? | BarSeriesOption

? ? | LineSeriesOption

? ? | TitleComponentOption

? ? | TooltipComponentOption

? ? | GridComponentOption

? ? | DatasetComponentOption

? ? >;



? ? // 注冊必須的組件

? ? echarts.use([

? ? TitleComponent,

? ? TooltipComponent,

? ? GridComponent,

? ? DatasetComponent,

? ? TransformComponent,

? ? BarChart,

? ? LineChart,

? ? PieChart,

? ? LabelLayout,

? ? UniversalTransition,

? ? CanvasRenderer

? ? ]);



? ? export default echarts

? ? 2、調用頁面代碼實例:

? ? import echarts from '@/plugins/echarts';

? ? // let myEchart1 = echarts.init(document.getElementById("draw")) // 切換頁面時不會顯示,解決辦法使用下面的

? ? // 解決一個charts不渲染的問題,認為dom沒有修改

? ? let dsiab_com = document.getElementById("draw")

? ? dsiab_com.removeAttribute("_echarts_instance_")

? ? var myEchart1 = echarts.init(dsiab_com)

? ? // 繪制圖表

? ? myEchart1.setOption({

? ? ? ? tooltip: {},

? ? ? ? xAxis: {

? ? ? ? data: ['襯衫', '羊毛衫', '雪紡衫', '褲子', '高跟鞋', '襪子']

? ? ? ? },

? ? ? ? yAxis: {},

? ? ? ? series: [

? ? ? ? {

? ? ? ? ? ? name: '銷量',

? ? ? ? ? ? type: 'line', // line折線圖,bar柱狀圖,pie

? ? ? ? ? ? data: [15, 210, 362, 103, 10, 20]

? ? ? ? },

? ? ? ? {

? ? ? ? ? ? name: '金額',

? ? ? ? ? ? type: 'bar', // line折線圖,bar柱狀圖,pie

? ? ? ? ? ? data: [5, 20, 36, 10, 10, 20]

? ? ? ? }

? ? ? ? ]

? ? });

```

? ? 7、npm i sass sass-loader -D 直接安裝即可使用文章來源地址http://www.zghlxwxcb.cn/news/detail-494083.html

到了這里,關于vue3+vite+ts+elementplus創(chuàng)建項目的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!

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

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

相關文章

  • 從0開始搭建一個vue3+vite+ts+pinia+element-plus的項目

    從0開始搭建一個vue3+vite+ts+pinia+element-plus的項目

    前言:vue3+ts+vite大家已經(jīng)都開始用了,最近也在學習,基本上是零基礎開始ts的學習,很多語法知識是邊寫邊查,沒有系統(tǒng)的學習ts。此處展示從零開始,搭建的一個框架,方便拿來即用! 其中框架選擇vue,語言選擇typeScript 項目啟動成功以后如下所示: 為了方便日常工作中

    2024年02月06日
    瀏覽(28)
  • 前端新手Vue3+Vite+Ts+Pinia+Sass項目指北系列文章 —— 第一章 技術棧簡介 (開篇)

    前端新手Vue3+Vite+Ts+Pinia+Sass項目指北系列文章 —— 第一章 技術棧簡介 (開篇)

    旨在幫助初學者掌握使用現(xiàn)代前端技術棧構建應用的基礎知識和技能。在這個系列中,我們將深入探討如何結合Vue.js、Vite、TypeScript、Pinia和Sass這些強大的工具和框架來開發(fā)現(xiàn)代化的前端應用。 通過這個系列,我們將從零開始構建一個完整的前端項目,覆蓋項目初始化、組件

    2024年02月05日
    瀏覽(30)
  • vue3+vite+pinia+vue-router+ol項目創(chuàng)建及配置

    vue3+vite+pinia+vue-router+ol項目創(chuàng)建及配置

    vite官網(wǎng) 注意:兩種方式創(chuàng)建目錄結構一致 方式一:vite創(chuàng)建腳手架命令: 命令行:npm create vite@latest 然后選擇 方式二:命令行直接聲明帶上vue 定義:pinia是一個是Vue官方團隊推薦代替Vuex的一款輕量級狀態(tài)管理庫。 pinia官網(wǎng)中文文檔 命令行:yarn add pinia 或者 npm i pinia vue-rou

    2024年02月16日
    瀏覽(125)
  • 前端新手Vue3+Vite+Ts+Pinia+Sass項目指北系列文章 —— 第十一章 基礎界面開發(fā) (組件封裝和使用)

    前端新手Vue3+Vite+Ts+Pinia+Sass項目指北系列文章 —— 第十一章 基礎界面開發(fā) (組件封裝和使用)

    Vue 是前端開發(fā)中非常常見的一種框架,它的易用性和靈活性使得它成為了很多開發(fā)者的首選。而在 Vue2 版本中,組件的開發(fā)也變得非常簡單,但隨著 Vue3 版本的發(fā)布,組件開發(fā)有了更多的特性和優(yōu)化,為我們的業(yè)務開發(fā)帶來了更多便利。本文將介紹如何使用 Vue3 開發(fā)業(yè)務組件

    2024年02月19日
    瀏覽(97)
  • 前端新手Vue3+Vite+Ts+Pinia+Sass項目指北系列文章 —— 第十二章 常用工具函數(shù) (Utils配置)

    前端新手Vue3+Vite+Ts+Pinia+Sass項目指北系列文章 —— 第十二章 常用工具函數(shù) (Utils配置)

    在項目開發(fā)中,我們經(jīng)常會使用一些工具函數(shù),也經(jīng)常會用到例如 loadsh 等工具庫,但是這些工具庫的體積往往比較大,如果項目本身已經(jīng)引入了這些工具庫,那么我們就沒有必要再引入一次,所以我們需要自己封裝一些工具函數(shù),來簡化我們的開發(fā)。 在 src/utils 目錄下創(chuàng)建

    2024年02月20日
    瀏覽(28)
  • 基于Vue3+TS+Vite+Cesium創(chuàng)建項目

    基于Vue3+TS+Vite+Cesium創(chuàng)建項目

    隨著近幾年社會的發(fā)展,人們對三維可視化的需求也是越來越多,三維GIS如今真的越來越火了,對于做GIS前端開發(fā)的人員來說,Cesium開發(fā)是絕對繞不開的一門技術,所以今天來說說如何利用當下最火的 Vue3+TS+Vite 來搭建一個基于Cesium的項目開發(fā)環(huán)境。 1.使用 yarn create vite 創(chuàng)建

    2024年02月05日
    瀏覽(22)
  • Uni-app + Vue3 + TS +Vite 創(chuàng)建項目

    Uni-app + Vue3 + TS +Vite 創(chuàng)建項目

    npm 都很熟,可是與 npm 如此相似的 npx 是干嘛的呢?我們?yōu)樯跻榻B npx ? 由于 uni-app 官方提供創(chuàng)建命令使用的是 npx,所以我們先來了解下 npx 是干什么的?它與 npm 的區(qū)別。 npx 是 npm 的高級版本,它從 npm v5.2 版本開始引入的,與 npm 綁定在一起,無需額外安裝,具有更大的功

    2023年04月15日
    瀏覽(22)
  • 【Vue H5項目實戰(zhàn)】從0到1的自助點餐系統(tǒng)—— 搭建腳手架(Vue3.2 + Vite + TS + Vant + Pinia + Node.js)

    【Vue H5項目實戰(zhàn)】從0到1的自助點餐系統(tǒng)—— 搭建腳手架(Vue3.2 + Vite + TS + Vant + Pinia + Node.js)

    H5 項目基于 Web 技術,可以在智能手機、平板電腦等移動設備上的瀏覽器中運行,無需下載和安裝任何應用程序,且H5 項目的代碼和資源可以集中在服務器端進行管理,只需更新服務器上的代碼,即可讓所有顧客訪問到最新的系統(tǒng)版本。 本系列將以肯德基自助點餐頁面為模板

    2024年02月13日
    瀏覽(132)
  • vue3 + TS + elementplus + pinia實現(xiàn)后臺管理系統(tǒng)左側菜單聯(lián)動實現(xiàn) tab根據(jù)路由切換聯(lián)動內容

    vue3 + TS + elementplus + pinia實現(xiàn)后臺管理系統(tǒng)左側菜單聯(lián)動實現(xiàn) tab根據(jù)路由切換聯(lián)動內容

    效果圖: ?home.vue頁面代碼 left.vue頁面代碼 tab.vue頁面代碼 pinia里面的代碼 安裝 使用插件 ?在main.ts中注冊 路由代碼 我把代碼放git上了,有需要的自行拉取 https://gitee.com/Flechazo7/vue3.git

    2024年02月09日
    瀏覽(27)
  • vue3+ts+pinia+vite一次性全搞懂

    前提是所處vue環(huán)境為vue3,如果失敗就查看一下環(huán)境是否為vue2,然后刪除vue2,安裝vue3 這是我報過的錯

    2024年02月01日
    瀏覽(23)

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

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

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

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

二維碼1

領取紅包

二維碼2

領紅包