最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue3中element-plus router的使用方式

 更新時(shí)間:2024年03月18日 08:59:23   作者:奧子  
這篇文章主要介紹了vue3中element-plus router的使用方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

vue3 element-plus router 使用

element plus 引入使用

//運(yùn)行 安裝 element-plus
 npm install element-plus --save
 
//運(yùn)行之后再 package.json 查看是否安裝成功  
 "dependencies": {
    "element-plus": "^2.2.6",
    "vue": "^3.2.8"
  }
  
//man.js 引入使用element plus  全部代碼塊全部粘貼 建議剛安裝vue3 直接復(fù)制下面代碼即可

import { createApp } from 'vue';
import App from './App.vue';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
createApp(App).use(ElementPlus).mount('#app')

//頁(yè)面 使用
<el-button>Default</el-button>
<el-button type="primary">Primary</el-button>

//注意當(dāng)我們使用特定的element-plus 組件時(shí)需要單獨(dú)引入 如 ElMessage 消息提醒,使用前先引入 
//import { ElMessage } from 'element-plus' ; 消息提示 復(fù)制

router 路由使用

//運(yùn)行安裝 router 
npm install vue-router@4

//查看是否安裝成功
 "dependencies": {
    "element-plus": "^2.2.6",
    "vue": "^3.2.8",
    "vue-router": "^4.0.16"
 }

//新建 文件夾view 和 router 文件 結(jié)構(gòu)

//index.js 文件
//引入 vue router 
import {createRouter, createWebHistory} from 'vue-router'
import routes from './routes'
 
const router = createRouter({
    history: createWebHistory(), 
    routes
})
 
export default router

//routes 文件
const routes = [
    {
        name: 'index',
        path: '/index',
        component: () => import('/src/view/index.vue')
    },
    {
        name: 'info',
        path: '/info',
        component: () => import('/src/view/info.vue')
    },
    
];
 
export default routes;

//man.js 引入
import router from './router/index';
import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import router from './router/index';
//多個(gè)可以使用 use鏈接使用
createApp(App).use(ElementPlus).use(router).mount('#app')

//app vue 使用 router-view 一定要加 不加不顯示路由頁(yè)面
<template>
  <router-view></router-view>
</template>

//在需要跳轉(zhuǎn)的頁(yè)面 /傳參 引入 注冊(cè) router
<script setup>
	import {useRouter } from "vue-router";
	const router = useRouter();
	const PathUrl = (param)=>{
	  router.push('/'+param+'?id=1'+'&ids=2')
	}
</script>

<template>
   <el-button type="primary" @click="PathUrl('index')">跳轉(zhuǎn)Index</el-button>
   <el-button type="success" @click="PathUrl('info')">跳轉(zhuǎn)info</el-button>
</template>

//router 接收參數(shù)
<script setup>
	import {useRoute } from "vue-router";
	const paramRoute = useRoute();
	console.log(paramRoute,paramRoute.query.id || '')
</script>


vue3怎么使用element-plus和vant3

element-plus

安裝配置

全局引入

npm install element-plus --save

在main.ts引入

import { createApp, Vue } from 'vue';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import App from './App.vue';

const app = createApp(App)
app.use(ElementPlus)
app.mount('#app')
//如果要多次引入 這樣來(lái)寫(xiě)
import { createApp } from 'vue'
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
const app = createApp(App)
//如果要多次引入 這樣來(lái)寫(xiě)
app.use(router).use(createPinia()).use(ElementPlus).mount('#app')

使用

這里使用的是按鈕

<el-row>
  <el-button>默認(rèn)按鈕</el-button>
  <el-button type="primary">主要按鈕</el-button>
  <el-button type="success">成功按鈕</el-button>
  <el-button type="info">信息按鈕</el-button>
  <el-button type="warning">警告按鈕</el-button>
  <el-button type="danger">危險(xiǎn)按鈕</el-button>
</el-row>

局部引入

  • 按需導(dǎo)入
  • 自動(dòng)導(dǎo)入組件以及樣式[推薦】

1.安裝插件

npm install element-plus --save

2.安裝自動(dòng)導(dǎo)入插件

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

3.配置vue.config.js(其他配置方式看官網(wǎng))

const AutoImport = require('unplugin-auto-import/webpack');
const Components = require('unplugin-vue-components/webpack');
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers');
module.exports = {
  configureWebpack: {
    resolve: {
      alias: {
        components: '@/components'
      }
    },
    //配置webpack自動(dòng)按需引入element-plus,
    plugins: [
      AutoImport({
        resolvers: [ElementPlusResolver()]
      }),
      Components({
        resolvers: [ElementPlusResolver()]
      })
    ]
  }
};

4.直接使用

<template>
    <div id="app">
      <el-row class="mb-4">
        <el-button disabled>Default</el-button>
        <el-button type="primary" disabled>Primary</el-button>
        <el-button type="success" disabled>Success</el-button>
        <el-button type="info" disabled>Info</el-button>
        <el-button type="warning" disabled>Warning</el-button>
        <el-button type="danger" disabled>Danger</el-button>
      </el-row>
    </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'

export default defineComponent({
})
</script>

<style lang="less">
</style>

vant3

安裝配置

全局引入

第一步

npm i vant@next -S

第2步(可寫(xiě)可不寫(xiě))

babel.comfig.js根目錄有就直接添加,

沒(méi)有就去創(chuàng)建 然后寫(xiě)入以下代碼

 plugins:[
    ['import',{
      libaryName:'vant',
      libaryDirectory:'es',
      style:true
    },'vant']
  ]

第3步

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'vant/lib/index.css'

import Vant from 'vant'

import './styles/index.less'

createApp(App).use(store).use(router).use(Vant).mount('#app')

最后

在對(duì)于頁(yè)面進(jìn)行使用

<template>
  <div id='app'>
    <van-button size="small" type="primary">Primary</van-button>
    <van-button type="info">Info</van-button>
    <van-button type="default">Default</van-button>
    <van-button type="danger">Danger</van-button>
    <van-button type="warning">Warning</van-button>
    <router-view/>
  </div>
</template>

<style lang="less"></style>

局部引入

npm i vant@next -S

在main.ts里面這樣寫(xiě)入 記得不要忘記引入css

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './style/reset.css'//vue3的resets必須在style里引入
//3的話引入reset.css需要在src里創(chuàng)建style 寫(xiě)入引入
// 不要在assets里創(chuàng)建css 寫(xiě)入引入 會(huì)報(bào)錯(cuò) 
// 需是在style的里面

// 局部引入vant
import 'vant/lib/index.css'
import { Swipe, SwipeItem, Toast, Field, Button, Cell, CellGroup, Tabbar, TabbarItem, Lazyload } from 'vant';
export const app = createApp(App)
app.use(Swipe).use(Lazyload).use(SwipeItem).use(Field).use(Toast).use(Button).use(Cell).use(CellGroup).use(Tabbar).use(TabbarItem)
app.use(store).use(router).mount('#app')

然后后期需要添加哪個(gè)就引用哪個(gè) 直接在需要的頁(yè)面使用就可 

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • 基于vue實(shí)現(xiàn)圖片預(yù)覽功能并顯示在彈窗的最上方

    基于vue實(shí)現(xiàn)圖片預(yù)覽功能并顯示在彈窗的最上方

    這篇文章主要為大家詳細(xì)介紹了如何基于vue實(shí)現(xiàn)圖片預(yù)覽功能并顯示在彈窗的最上方,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2024-10-10
  • Vue.Draggable拖拽功能的配置使用方法

    Vue.Draggable拖拽功能的配置使用方法

    這篇文章主要為大家詳細(xì)介紹了Vue.Draggable拖拽功能配置使用的方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-12-12
  • Vue?關(guān)于Store的用法小結(jié)

    Vue?關(guān)于Store的用法小結(jié)

    Vue?Store是的狀態(tài)管理模式和庫(kù),它提供了一種集中存儲(chǔ)管理應(yīng)用的所有組件的狀態(tài),并以相應(yīng)的規(guī)則保證狀態(tài)以一種可預(yù)測(cè)的方式發(fā)生變化,這篇文章主要介紹了Vue?關(guān)于Store的用法,需要的朋友可以參考下
    2024-08-08
  • Vue.js單向綁定和雙向綁定實(shí)例分析

    Vue.js單向綁定和雙向綁定實(shí)例分析

    這篇文章主要介紹了Vue.js單向綁定和雙向綁定,結(jié)合實(shí)例形式分析了vue.js單向綁定與雙向綁定相關(guān)原理、實(shí)現(xiàn)方法及操作技巧,需要的朋友可以參考下
    2018-08-08
  • 前端實(shí)現(xiàn)Vue組件頁(yè)面跳轉(zhuǎn)的多種方式小結(jié)

    前端實(shí)現(xiàn)Vue組件頁(yè)面跳轉(zhuǎn)的多種方式小結(jié)

    這篇文章主要為大家詳細(xì)介紹了前端實(shí)現(xiàn)Vue組件頁(yè)面跳轉(zhuǎn)的多種方式,文中的示例代碼講解詳細(xì),具有一定的參考價(jià)值,有需要的小伙伴可以了解下
    2024-02-02
  • Vue實(shí)現(xiàn)子組件向父組件傳遞多個(gè)參數(shù)的方法

    Vue實(shí)現(xiàn)子組件向父組件傳遞多個(gè)參數(shù)的方法

    在Vue框架中,組件間的通信是一個(gè)常見(jiàn)的需求,特別是在子組件需要向父組件傳遞多個(gè)參數(shù)時(shí),合理的通信方式可以顯著提升代碼的可讀性和可維護(hù)性,本文將詳細(xì)介紹如何在Vue中實(shí)現(xiàn)子組件向父組件傳遞多個(gè)參數(shù),需要的朋友可以參考下
    2024-10-10
  • vue3+elementplus基于el-table-v2封裝公用table組件詳細(xì)代碼

    vue3+elementplus基于el-table-v2封裝公用table組件詳細(xì)代碼

    在日常開(kāi)發(fā)后端管理系統(tǒng)項(xiàng)目中,用于展示數(shù)據(jù)多會(huì)用表格進(jìn)行展示,下面這篇文章主要給大家介紹了關(guān)于vue3+elementplus基于el-table-v2封裝公用table組件的相關(guān)資料,需要的朋友可以參考下
    2023-12-12
  • vue多級(jí)多選菜單組件開(kāi)發(fā)

    vue多級(jí)多選菜單組件開(kāi)發(fā)

    這篇文章主要為大家分享了vue多級(jí)多選菜單組件開(kāi)發(fā)案例,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-10-10
  • vue2.0如何動(dòng)態(tài)綁定img的src屬性(三元運(yùn)算)

    vue2.0如何動(dòng)態(tài)綁定img的src屬性(三元運(yùn)算)

    這篇文章主要介紹了vue2.0如何動(dòng)態(tài)綁定img的src屬性(三元運(yùn)算)問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-08-08
  • vue基于Teleport實(shí)現(xiàn)Modal組件

    vue基于Teleport實(shí)現(xiàn)Modal組件

    Teleport 提供了一種干凈的方法,允許我們控制在 DOM 中哪個(gè)父節(jié)點(diǎn)下渲染了 HTML,而不必求助于全局狀態(tài)或?qū)⑵洳鸱譃閮蓚€(gè)組件。
    2021-05-05

最新評(píng)論

和静县| 古丈县| 凤台县| 临潭县| 桐城市| 华安县| 宜都市| 靖边县| 武清区| 高雄县| 玛沁县| 宁晋县| 万荣县| 久治县| 四川省| 依安县| 临潭县| 仁怀市| 霞浦县| 武威市| 灵台县| 浦江县| 车致| 禹城市| 怀仁县| 鹤山市| 噶尔县| 洪江市| 玛沁县| 巴马| 长春市| 大安市| 虎林市| 南昌市| 清流县| 宁乡县| 安多县| 建始县| 新沂市| 乐东| 攀枝花市|