第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

vue.js v-for里套slot,如何訪問v-for當(dāng)前值?

vue.js v-for里套slot,如何訪問v-for當(dāng)前值?

DIEA 2018-08-07 16:10:31
我寫個(gè)組件,想實(shí)現(xiàn)這樣的效果:<info-list @on_data="fetch_data">    <info-item title_field="xxx" link="/xxx/{{ item.id }}"/> </info-list>然后List的模板大概這樣:<script type="x/template" id="info-list">   ...  <div v-for="item in items">     <slot></slot>   </div>   ...</script>Item的模板大概這樣:<script type="x/template" id="info-item">   .....  <a href="{{ link }}">{{ item[title_field] }}</a>  ......</script>主要是問題是,slot里的組件,如何訪問外層的狀態(tài)。我看到stackoverflow也有人問類似的問題:http://stackoverflow.com/questions/37248411/how-to-access-item-in-slot-inside-v-for-vue-js還有:http://forum.vuejs.org/topic/366/slot-as-an-item-row-template/6
查看完整描述

2 回答

?
藍(lán)山帝景

TA貢獻(xiàn)1843條經(jīng)驗(yàn) 獲得超7個(gè)贊

只能這樣:

<info-list @on_data="fetch_data">   <info-item v-for="item in items"/></info-list>

slot 是在父組件被編譯的,所以其作用域(scope)是在父組件,沒辦法在子組件傳值給 slot,可能要考慮改變下結(jié)構(gòu)。


查看完整回答
反對 回復(fù) 2018-09-19
  • 2 回答
  • 0 關(guān)注
  • 2484 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)