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

vue實(shí)現(xiàn)tab欄切換效果

 更新時(shí)間:2022年09月01日 10:07:40   作者:凡小多  
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)tab欄切換效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue實(shí)現(xiàn)tab欄切換效果的具體代碼,供大家參考,具體內(nèi)容如下

一個(gè)簡單的tab欄切換組件,由tabs以及tab-pane組成

效果圖

使用

<template>
? <div class="container">
? ? <tabs
? ? ? default-active="2"
? ? ? class="build-tabs"
? ? >
? ? ? <tab-pane
? ? ? ? label="tab欄標(biāo)題1"
? ? ? ? index="1"
? ? ? >tab欄內(nèi)容1</tab-pane>
? ? ? <tab-pane
? ? ? ? label="tab欄標(biāo)題tab欄標(biāo)題2"
? ? ? ? index="2"
? ? ? >
? ? ? ? tab欄內(nèi)容2
? ? ? </tab-pane>
? ? ? <tab-pane
? ? ? ? label="tab欄標(biāo)題"
? ? ? ? index="3"
? ? ? >tab欄內(nèi)容3</tab-pane>
? ? ? <tab-pane
? ? ? ? label="標(biāo)題"
? ? ? ? index="4"
? ? ? >tab欄內(nèi)容4</tab-pane>
? ? ? <tab-pane
? ? ? ? label="tab欄標(biāo)題3"
? ? ? ? index="5"
? ? ? >tab欄內(nèi)容5</tab-pane>
? ? </tabs>
? </div>
</template>

tabs

<template>
? <div
? ? v-show="pans.length"
? ? class="tabs"
? >
? ? <div class="tab-title">
? ? ? <div
? ? ? ? v-for="(item) in pans"
? ? ? ? :key="item.id"
? ? ? ? class="item"
? ? ? ? :class="{ 'active': currentActive === item.index }"
? ? ? ? @click="changeTab(item.index)"
? ? ? >{{ item.label }}</div>
? ? </div>
? ? <div class="tab-content">
? ? ? <slot></slot>
? ? </div>
? </div>
</template>

<script>
export default {
? props: {
? ? mode: {
? ? ? type: String,
? ? ? default: "horizontal/vertical"
? ? },
? ? defaultActive: {
? ? ? type: String | Number,
? ? ? default: '1'
? ? },
? ? defaultColor: {
? ? ? type: String,
? ? ? default: '#409EFF'
? ? }
? },
? data: () => {
? ? return {
? ? ? currentActive: '',
? ? ? pans: []
? ? }
? },
? computed: {

? },
? watch: {
? ? defaultActive: {
? ? ? handler (newVal) {
? ? ? ? this.currentActive = newVal
? ? ? },
? ? ? immediate: true
? ? }
? },
? mounted () {
? },

? methods: {
? ? changeTab (val) {
? ? ? this.currentActive = val
? ? },
? }
}
</script>
<style scoped lang="scss">
::root {
? --color: "#409EFF";
}
.tabs {
? .tab-title {
? ? display: flex;
? ? // align-items: flex-start;
? ? align-items: stretch;?? ?// 側(cè)邊欄時(shí),使側(cè)欄高度與內(nèi)容高度一致,按最高的顯示
? ? margin-bottom: 14px;
? ? border-bottom: 1px solid #ccc;
? ? .item {
? ? ? padding: 20px;
? ? ? /* padding-bottom: 20px; */
? ? ? cursor: pointer;
? ? ? white-space: nowrap;
? ? }
? ? .active {
? ? ? // color: var(--color);
? ? ? color: #409EFF;
? ? ? /* padding-bottom: 15px; // 修正邊框值:20px - 5px = 15px */
? ? ? border-bottom: 5px solid #409EFF;
? ? ? background-image: linear-gradient(
? ? ? ? to top,
? ? ? ? rgba($color: #409EFF, $alpha: 0.2),
? ? ? ? transparent
? ? ? );
? ? }
? }
}
</style>

tab-pane

<template>
? <div
? ? v-show="show && renderPan"
? ? class="tab-pane"
? >
? ? <slot></slot>
? </div>
</template>
<script>
export default {
? name: 'tabPane',
? props: {
? ? index: {
? ? ? type: [String, Number],
? ? ? default: ''
? ? },
? ? label: {
? ? ? type: String,
? ? ? required: true
? ? }
? },
? data: () => {
? ? return {
? ? ? renderPan: false
? ? }
? },
? computed: {
? ? show () {
? ? ? if (this.$parent.currentActive === this.index) return true
? ? ? return false
? ? }
? },
? mounted () {
? ? this.$parent.pans.push({ id: Date.parse(new Date()) + Math.random(), index: this.index, label: this.label });
? ? this.renderPan = true
? },
? methods: {
? },
}
</script>
<style scoped lang="scss">
</style>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Vue中如何引用公共方法和公共組件

    Vue中如何引用公共方法和公共組件

    這篇文章主要介紹了Vue中如何引用公共方法和公共組件問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-05-05
  • 搭建element-ui的Vue前端工程操作實(shí)例

    搭建element-ui的Vue前端工程操作實(shí)例

    下面小編就為大家分享一篇搭建element-ui的Vue前端工程操作實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-02-02
  • Vue axios 中提交表單數(shù)據(jù)(含上傳文件)

    Vue axios 中提交表單數(shù)據(jù)(含上傳文件)

    本篇文章主要介紹了Vue axios 中提交表單數(shù)據(jù)(含上傳文件),具有一定的參考價(jià)值,有興趣的可以了解一下
    2017-07-07
  • vue中使用el-dropdown方式

    vue中使用el-dropdown方式

    這篇文章主要介紹了vue中使用el-dropdown方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-08-08
  • Vuex中五個(gè)屬性以及使用方法詳解

    Vuex中五個(gè)屬性以及使用方法詳解

    這篇文章主要給大家介紹了關(guān)于Vuex中五個(gè)屬性以及使用的相關(guān)資料,Vuex是一個(gè)專為Vue.js應(yīng)用程序開發(fā)的狀態(tài)管理模式,文中通過代碼示例介紹的非常詳細(xì),需要的朋友可以參考下
    2023-09-09
  • mint-ui在vue中的使用示例

    mint-ui在vue中的使用示例

    Mint UI 是 由餓了么前端團(tuán)隊(duì)推出的 一個(gè)基于 Vue.js 的移動(dòng)端組件庫,這篇文章主要介紹了mint-ui在vue中的使用示例,這里整理了詳細(xì)的代碼,有需要的小伙伴可以參考下
    2018-04-04
  • VUE實(shí)現(xiàn)一個(gè)分頁組件的示例

    VUE實(shí)現(xiàn)一個(gè)分頁組件的示例

    本篇文章主要介紹了VUE實(shí)現(xiàn)一個(gè)分頁組件的示例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-09-09
  • vue3頁面加載完成后如何獲取寬度、高度

    vue3頁面加載完成后如何獲取寬度、高度

    這篇文章主要介紹了vue3頁面加載完成后如何獲取寬度、高度問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-04-04
  • vue項(xiàng)目實(shí)現(xiàn)圖形驗(yàn)證碼

    vue項(xiàng)目實(shí)現(xiàn)圖形驗(yàn)證碼

    這篇文章主要為大家詳細(xì)介紹了vue項(xiàng)目實(shí)現(xiàn)圖形驗(yàn)證碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-04-04
  • vue實(shí)現(xiàn)列表展示示例詳解

    vue實(shí)現(xiàn)列表展示示例詳解

    這篇文章主要為大家介紹了vue實(shí)現(xiàn)列表展示的示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07

最新評論

夏邑县| 汽车| 嘉义市| 长武县| 泰州市| 随州市| 浏阳市| 吴堡县| 临猗县| 崇礼县| 邯郸县| 双江| 佛坪县| 仁怀市| 灌阳县| 文昌市| 静海县| 新化县| 娱乐| 万盛区| 齐齐哈尔市| 凭祥市| 古交市| 琼海市| 正安县| 巧家县| 任丘市| 莱阳市| 自治县| 会宁县| 庐江县| 罗山县| 萍乡市| 闽清县| 许昌县| 郯城县| 邵阳市| 鹤岗市| 灯塔市| 垣曲县| 灵川县|