在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML5  HTML/ 關(guān)于vue中slot,在父組件獲取數(shù)據(jù)時(shí)scope與slot-scope的區(qū)別

關(guān)于vue中slot,在父組件獲取數(shù)據(jù)時(shí)scope與slot-scope的區(qū)別

組件

<div v-for="item in list">
    <slot></slot>
</div>

使用

<my-component :list="data">
    <div>
        <!--這里需要使用item中的內(nèi)容-->
        <!--怎樣才能在這里獲取到list里面循環(huán)出的內(nèi)容呢-->
    </div>
</my-component>
回答
編輯回答
尐懶貓

<div v-for="item in list">

<slot :text= "item"></slot>

</div
<my-component :list="data">

<template slot-scope="props">
     <div>
    <!--這里需要使用item中的內(nèi)容-->
    <!--怎樣才能在這里獲取到list里面循環(huán)出的內(nèi)容呢-->
    {{props.text}}
    </div>
</template>

</my-component>

看一下這個(gè)行不

2018年1月26日 12:37
編輯回答
墨沫

你的版本不是2.5.X的吧
圖片描述

2018年3月25日 23:03
編輯回答
墻頭草

現(xiàn)在數(shù)據(jù)獲取問(wèn)題解決了,但是為啥我用slot-scope就報(bào)錯(cuò),用scope才能正常獲取數(shù)據(jù),官網(wǎng)使用的都是slot-scope啊

2018年3月2日 01:30