新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)VUE3教程:Vue 3.0 Slot統(tǒng)一
#概覽
此更改統(tǒng)一了 3.x 中的普通 slot 和作用域 slot。

清河門ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為成都創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書合作)期待與您的合作!
以下是變化的變更總結(jié):
this.$slots現(xiàn)在將 slots 作為函數(shù)公開- 非兼容:移除
this.$scopedSlots
更多信息,請繼續(xù)閱讀!
#2.x 語法
當(dāng)使用渲染函數(shù)時,即 h,2.x 用于在內(nèi)容節(jié)點(diǎn)上定義 slot data property。
// 2.x 語法
h(LayoutComponent, [
h('div', { slot: 'header' }, this.header),
h('div', { slot: 'content' }, this.content)
])此外,在引用作用域 slot 時,可以使用以下方法引用它們:
// 2.x 語法
this.$scopedSlots.header#3.x 語法
在 3.x 中,插槽被定義為當(dāng)前節(jié)點(diǎn)的子對象:
// 3.x Syntax
h(LayoutComponent, {}, {
header: () => h('div', this.header),
content: () => h('div', this.content)
}) 當(dāng)你需要以編程方式引用作用域 slot 時,它們現(xiàn)在被統(tǒng)一到 $slots 選項(xiàng)中。
// 2.x 語法
this.$scopedSlots.header
// 3.x 語法
this.$slots.header#遷移策略
大部分更改已經(jīng)在 2.6 中發(fā)布。因此,遷移可以一步到位:
- 在 3.x 中,將所有
this.$scopedSlots替換為this.$slots。
本文名稱:創(chuàng)新互聯(lián)VUE3教程:Vue 3.0 Slot統(tǒng)一
文章路徑:http://m.5511xx.com/article/dphohhi.html


咨詢
建站咨詢
