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

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

Vue:如何使用自定義 v-slot dom 構(gòu)建組件?

Vue:如何使用自定義 v-slot dom 構(gòu)建組件?

回首憶惘然 2021-11-12 16:43:03
現(xiàn)在我有一個自定義組件,并且我使用了一個自定義渲染函數(shù):<script>export default {  render(h) {    return h('InnerComponent', h('div', 'My Content'))  }}</script>和InnerComponent被定義為如下:<template>  <div>    <div>Default slot: <slot></slot></div>    <div>Custom slot: <slot name="custom"></slot></div>  </div></template>所以內(nèi)容h('div', 'My Content')被注入到默認(rèn)槽中,最后渲染如下:<div>  <div>Default slot: <div>My Content</div></div>  <div>Custom slot: </div></div>那么如果我想將該內(nèi)容注入到自定義插槽中呢?( <slot name="custom"></slot>),在渲染函數(shù)中,就像我們在下面的模板中使用的那樣?<template>  <InnerComponent>    <div v-slot:custom>My Content</div>  </InnerComponent></template><script>export default {}</script>
查看完整描述

1 回答

?
躍然一笑

TA貢獻(xiàn)1826條經(jīng)驗 獲得超6個贊

相關(guān)文檔:https : //vuejs.org/v2/guide/render-function.html#The-Data-Object-In-Depth

您只需要slot在孩子的選項中指定一個:

h('div', { slot: 'custom' }, 'My Content')


查看完整回答
反對 回復(fù) 2021-11-12
  • 1 回答
  • 0 關(guān)注
  • 148 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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