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

v-slot和slot、slot-scope之間相互替換實(shí)例

 更新時(shí)間:2020年09月04日 11:27:23   作者:摸咸魚  
這篇文章主要介紹了v-slot和slot、slot-scope之間相互替換實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧

如果組件文檔里面用的是v-slot,而你用的是vue2.6之前的版本,則需要替換v-slot:所以有兩種替換方式,注意看兩塊v-slot有啥不同,你就知道你該怎么用slot-scope和slot來替換文檔中的v-slot了

v-slot使用方式1:

<template v-slot:operate="{ row }"><template>

則可替換為:

<template slot="operate" slot-scope="{ row }"></template>

v-slot使用方式2:

<template v-slot="{ row }"><template>

則可替換為:

<template slot-scope="row"></template>

先記錄后期再完善,趕項(xiàng)目去了

補(bǔ)充知識(shí):V-for and slot-scoped報(bào)錯(cuò)問題

此場景是為了用v-for動(dòng)態(tài)渲染表格的slot

可能會(huì)這么寫

<a-table>
 <span v-for="(item, index) in header" :key="index" :slot="item.dataIndex" slot-scope="text" >
  {{ text }}
 </span>
</a-table>

但是這樣子會(huì)報(bào)錯(cuò),因?yàn)関-for和slot-scope在同一級

Ambiguous combined usage of slot-scope and v-for on (v-for takes higher priority). Use a wrapper < template> for the scoped slot to make it clearer.

提示在外邊包一層< template>,于是你可能改成下面這樣,但是也會(huì)報(bào)錯(cuò)

<a-table>
 <template v-for="(item, index) in header" :key="index">
 <span :slot="item.dataIndex" slot-scope="text" >
  {{ text }}
 </span>
 </template>
</a-table>
< template> cannot be keyed. Place the key on real elements instead.

提示< template>template不能寫key, 即使沒有這個(gè)錯(cuò),表格數(shù)據(jù)也不會(huì)渲染出來,因?yàn)檫@一層沒有slot,應(yīng)該說slot應(yīng)該是放最外面,同時(shí)把:key放里面

改成如下

<a-table>
 <template v-for="(item, index) in header" :slot="item.dataIndex" slot-scope="text">
 <span :key="index">
  {{ text }}
 </span>
 </template>
</a-table>

以上解決問題

有個(gè)slot沒有渲染的問題

 <template v-for="(slotname, idx) in ['status', 'sub_account_status']" :slot="slotname" slot-scope="text" >
  <span :key="idx">
  <a-tag v-if="text === '正常'" color="blue">{{ text }}</a-tag>
  <a-tag v-else color="red">{{ text }}</a-tag>
  </span>
 </template>
 <!-- 包名稱、關(guān)聯(lián)賬號(hào) -->
 <template v-for="(slotname, idx) in ['app_name', 'roles']" :slot="slotname" slot-scope="text" >
  <span :key="idx">
  <a-tooltip placement="top" >
  <template slot="title">
  <span v-for="(item, index) in text" :key="index">{{ item }}<br/></span>
  </template>
  <div class="tableHidden">
  <a-tag v-for="(item, index) in text" :key="index">{{ item }} </a-tag>
  </div>
  </a-tooltip>
  </span>
 </template>

好像是因?yàn)?個(gè)v-for="(slotname, idx)"里的slotname名字一樣了,對的,就是取的臨時(shí)變量名,修改成不一樣的就好了,神奇

 <template v-for="(name, idx) in ['status', 'sub_account_status']" :slot="name" slot-scope="text" >
  // 上面那個(gè)name
  <span :key="idx">
  。。。
  </span>
 </template>
 <!-- 包名稱、關(guān)聯(lián)賬號(hào) -->
 <template v-for="(slotname, idx) in ['app_name', 'roles']" :slot="slotname" slot-scope="text" >
  <span :key="idx">
  。。。
  </a-tooltip>
  </span>
 </template>

以上這篇v-slot和slot、slot-scope之間相互替換實(shí)例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue3實(shí)現(xiàn)移動(dòng)端滑動(dòng)模塊

    vue3實(shí)現(xiàn)移動(dòng)端滑動(dòng)模塊

    這篇文章主要為大家詳細(xì)介紹了vue3實(shí)現(xiàn)移動(dòng)端滑動(dòng)模塊,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-09-09
  • vue實(shí)現(xiàn)驗(yàn)證碼倒計(jì)時(shí)按鈕

    vue實(shí)現(xiàn)驗(yàn)證碼倒計(jì)時(shí)按鈕

    這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)驗(yàn)證碼倒計(jì)時(shí)按鈕,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • vue混入mixin流程與優(yōu)缺點(diǎn)詳解

    vue混入mixin流程與優(yōu)缺點(diǎn)詳解

    混入(mixin)提供了一種非常靈活的方式,來分發(fā)vue組件中的可復(fù)用功能。一個(gè)混入對象可以包含任意組件選項(xiàng)。當(dāng)組件使用混入對象時(shí),所有混入對象的選項(xiàng)將被“混合”進(jìn)入該組件本身的選項(xiàng)
    2022-09-09
  • vue2 拖動(dòng)排序 vuedraggable組件的實(shí)現(xiàn)

    vue2 拖動(dòng)排序 vuedraggable組件的實(shí)現(xiàn)

    這篇文章主要介紹了vue2 拖動(dòng)排序 vuedraggable組件的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-08-08
  • vue3升級常見問題詳細(xì)匯總

    vue3升級常見問題詳細(xì)匯總

    隨著vue3?的發(fā)布和越來越多項(xiàng)目的使用,之前使用?vue2?的項(xiàng)目也不能拉下,vue2?升級?vue3?迫在眉睫,下面這篇文章主要給大家介紹了關(guān)于vue3升級常見問題的相關(guān)資料,需要的朋友可以參考下
    2023-03-03
  • vue elementUI 上傳非空驗(yàn)證示例代碼

    vue elementUI 上傳非空驗(yàn)證示例代碼

    這篇文章主要介紹了vue elementUI 上傳非空驗(yàn)證,原理就是寫一個(gè)假的紅色*號(hào),每次點(diǎn)擊查看的時(shí)候執(zhí)this.rules.staffImg[0].required = false,本文結(jié)合實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友參考下吧
    2023-12-12
  • vue綁定的點(diǎn)擊事件阻止冒泡的實(shí)例

    vue綁定的點(diǎn)擊事件阻止冒泡的實(shí)例

    下面小編就為大家分享一篇vue綁定的點(diǎn)擊事件阻止冒泡的實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-02-02
  • vue 實(shí)現(xiàn)單選框設(shè)置默認(rèn)選中值

    vue 實(shí)現(xiàn)單選框設(shè)置默認(rèn)選中值

    今天小編就為大家分享一篇vue 實(shí)現(xiàn)單選框設(shè)置默認(rèn)選中值,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-11-11
  • vue props 單項(xiàng)數(shù)據(jù)流實(shí)例分享

    vue props 單項(xiàng)數(shù)據(jù)流實(shí)例分享

    在本篇文章里小編給大家分享的是一篇關(guān)于vue props 單項(xiàng)數(shù)據(jù)流實(shí)例分享內(nèi)容,需要的朋友們可以參考下。
    2020-02-02
  • 關(guān)于element Drawer抽屜的使用

    關(guān)于element Drawer抽屜的使用

    這篇文章主要介紹了關(guān)于element Drawer抽屜的使用方式,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-07-07

最新評論

岳阳市| 集安市| 张家川| 连城县| 庄河市| 晋江市| 泉州市| 双鸭山市| 柘荣县| 临清市| 邹城市| 曲靖市| 珠海市| 全椒县| 乌兰县| 沂南县| 高唐县| 拉孜县| 襄汾县| 芦溪县| 西畴县| 河曲县| 丹江口市| 莲花县| 龙岩市| 临清市| 台湾省| 育儿| 如东县| 余姚市| 光泽县| 卢湾区| 乾安县| 屯留县| 和田县| 比如县| 江安县| 桃江县| 凭祥市| 元阳县| 阿拉善右旗|