欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

BootstrapVue選項(xiàng)卡標(biāo)題增加關(guān)閉按鈕的方法

 更新時間:2022年04月01日 10:21:09   作者:titan80001  
這篇文章主要為大家詳細(xì)介紹了BootstrapVue選項(xiàng)卡標(biāo)題增加關(guān)閉按鈕的方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

BootstrapVue選項(xiàng)卡標(biāo)題增加關(guān)閉按鈕,供大家參考,具體內(nèi)容如下

BootstrapVue官網(wǎng)選項(xiàng)卡組件中,沒有列出選項(xiàng)卡標(biāo)題帶關(guān)閉按鈕的,這里參照官網(wǎng)的例子進(jìn)行修改,給標(biāo)題加上關(guān)閉按鈕。

官網(wǎng)舉例:

<template>
? <div>
? ? <b-card no-body>
? ? ? <b-tabs card>
? ? ? ? <!-- Render Tabs, supply a unique `key` to each tab -->
? ? ? ? <b-tab v-for="i in tabs" :key="'dyn-tab-' + i" :title="'Tab ' + i">
? ? ? ? ? Tab contents {{ i }}
? ? ? ? ? <b-button size="sm" variant="danger" class="float-right" @click="closeTab(i)">
? ? ? ? ? ? Close tab
? ? ? ? ? </b-button>
? ? ? ? </b-tab>

? ? ? ? <!-- New Tab Button (Using tabs-end slot) -->
? ? ? ? <template v-slot:tabs-end>
? ? ? ? ? <b-nav-item @click.prevent="newTab" href="#" ><b>+</b></b-nav-item>
? ? ? ? </template>

? ? ? ? <!-- Render this if no tabs -->
? ? ? ? <template v-slot:empty>
? ? ? ? ? <div class="text-center text-muted">
? ? ? ? ? ? There are no open tabs<br>
? ? ? ? ? ? Open a new tab using the <b>+</b> button above.
? ? ? ? ? </div>
? ? ? ? </template>
? ? ? </b-tabs>
? ? </b-card>
? </div>
</template>

<script>
? export default {
? ? data() {
? ? ? return {
? ? ? ? tabs: [],
? ? ? ? tabCounter: 0
? ? ? }
? ? },
? ? methods: {
? ? ? closeTab(x) {
? ? ? ? for (let i = 0; i < this.tabs.length; i++) {
? ? ? ? ? if (this.tabs[i] === x) {
? ? ? ? ? ? this.tabs.splice(i, 1)
? ? ? ? ? }
? ? ? ? }
? ? ? },
? ? ? newTab() {
? ? ? ? this.tabs.push(this.tabCounter++)
? ? ? }
? ? }
? }
</script>

利用插槽向選項(xiàng)卡標(biāo)題添加icon圖標(biāo),選關(guān)閉按鈕圖形,并綁定關(guān)閉事件。修改后代碼如下:

<template>
? <div>
? ? <div>
? ? ? ? ? <b-nav-item @click.prevent="newTab" href="#" ><b>添加Tab頁</b></b-nav-item>
? ? </div>

? ? <div>
? ? ? <b-card no-body>
? ? ? ? <b-tabs card>
? ? ? ? ? <!-- Render Tabs, supply a unique `key` to each tab -->
? ? ? ? ? <b-tab v-for="i in tabs" :key="'dyn-tab-' + i">
? ? ? ? ? ? <!--用插槽想標(biāo)題添加icon圖標(biāo),同時將關(guān)閉按鈕調(diào)用的時間轉(zhuǎn)移到圖標(biāo)的點(diǎn)擊事件中執(zhí)行-->
? ? ? ? ? ? <template v-slot:title>
? ? ? ? ? ? ? ? ? ? Tab{{ i }}
? ? ? ? ? ? ? ? ? ? <!--插入icon圖標(biāo),關(guān)閉按鈕圖形-->
? ? ? ? ? ? ? ? ? ? <a @click="closeTab(i)">
? ? ? ? ? ? ? ? ? ? ? ? <b-icon icon="x-square"></b-icon>
? ? ? ? ? ? ? ? ? ? </a>
? ? ? ? ? ? </template>
? ? ? ? ? ? <h1> Tab-{{i}} </h1>

? ? ? ? ? </b-tab>

? ? ? ? ? <!-- New Tab Button (Using tabs-end slot) -->
? ? ? ? ? <!-- Render this if no tabs -->
? ? ? ? ? <template v-slot:empty>
? ? ? ? ? ? <div class="text-center text-muted">
? ? ? ? ? ? ? There are no open tabs<br>
? ? ? ? ? ? ? Open a new tab using the <b>+</b> button above.
? ? ? ? ? ? </div>
? ? ? ? ? </template>
? ? ? ? </b-tabs>
? ? ? </b-card>
? ? </div>

? </div>
</template>

<script>
export default {
? data () {
? ? return {
? ? ? tabs: [],
? ? ? tabCounter: 0
? ? }
? },
? methods: {
? ? closeTab (x) {
? ? ? for (let i = 0; i < this.tabs.length; i++) {
? ? ? ? if (this.tabs[i] === x) {
? ? ? ? ? this.tabs.splice(i, 1)
? ? ? ? }
? ? ? }
? ? },
? ? newTab () {
? ? ? this.tabs.push(this.tabCounter++)
? ? }
? }
}
</script>

官網(wǎng)標(biāo)簽鏈接

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

相關(guān)文章

  • bootstrap multiselect 多選功能實(shí)現(xiàn)方法

    bootstrap multiselect 多選功能實(shí)現(xiàn)方法

    這篇文章主要介紹了bootstrap multiselect 多選功能實(shí)現(xiàn)方法,需要的朋友可以參考下
    2017-06-06
  • JavaScript數(shù)組的一些奇葩行為

    JavaScript數(shù)組的一些奇葩行為

    今天,復(fù)習(xí)了一下JavaScript的數(shù)組,然后,把他的一些奇葩行為總結(jié)了一下,分享在腳本之家平臺,歡迎大家參考
    2016-01-01
  • 微信小程序在web-view頁面增加一個按鈕具體代碼

    微信小程序在web-view頁面增加一個按鈕具體代碼

    web-view是一個可以用來承載網(wǎng)頁的容器,會自動鋪滿整個小程序頁面,這篇文章主要給大家介紹了關(guān)于微信小程序在web-view頁面增加一個按鈕的具體代碼,需要的朋友可以參考下
    2023-10-10
  • JavaScript獲取圖片像素顏色并轉(zhuǎn)換為box-shadow顯示

    JavaScript獲取圖片像素顏色并轉(zhuǎn)換為box-shadow顯示

    這篇文章主要介紹了JavaScript獲取圖片像素顏色并轉(zhuǎn)換為box-shadow顯示的方法,用到了HTML5中的FileReader API和getImageData,轉(zhuǎn)換為的CSS3 box-shadow也要注意瀏覽器的兼容問題,需要的朋友可以參考下
    2016-03-03
  • javascript求日期差的方法

    javascript求日期差的方法

    這篇文章主要介紹了javascript求日期差的方法,涉及JavaScript日期及字符串操作的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2016-03-03
  • JS基于Ajax實(shí)現(xiàn)的網(wǎng)頁Loading效果代碼

    JS基于Ajax實(shí)現(xiàn)的網(wǎng)頁Loading效果代碼

    這篇文章主要介紹了JS基于Ajax實(shí)現(xiàn)的網(wǎng)頁Loading效果代碼,通過時間函數(shù)結(jié)合數(shù)學(xué)運(yùn)算實(shí)現(xiàn)頁面樣式的動態(tài)變換技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-10-10
  • 實(shí)例詳解JavaScript中setTimeout函數(shù)的執(zhí)行順序

    實(shí)例詳解JavaScript中setTimeout函數(shù)的執(zhí)行順序

    關(guān)于javascript的運(yùn)行機(jī)制大家都應(yīng)該有所了解了吧,其實(shí)javascript是一個單線程的機(jī)制,但是因?yàn)殛?duì)列的關(guān)系它的表現(xiàn)會讓我們感覺是一個多線程的錯覺。下面這篇文章通過實(shí)例主要給大家介紹了關(guān)于JavaScript中setTimeout函數(shù)執(zhí)行順序的相關(guān)資料,需要的朋友可以參考下。
    2017-07-07
  • TypeScript中的方法重載詳解

    TypeScript中的方法重載詳解

    這篇文章主要給大家介紹了關(guān)于TypeScript中方法重載的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用TypeScript具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • JS操作字符串的一些常見內(nèi)置方法

    JS操作字符串的一些常見內(nèi)置方法

    這篇文章主要給大家介紹了關(guān)于JS操作字符串的一些常見內(nèi)置方法,JavaScript中有許多常用的數(shù)組和字符串操作函數(shù),文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-11-11
  • JS正則替換掉小括號及內(nèi)容的方法

    JS正則替換掉小括號及內(nèi)容的方法

    下面小編就為大家?guī)硪黄狫S正則替換掉小括號及內(nèi)容的方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-11-11

最新評論