超碰中文网,91久久精品日日躁夜夜躁欧美,一区二区三区精品道,一区二区国产在线观看,亚洲精品中文字幕乱码一区二区,天天看片高清影视在线观看,久久99精品久久久久蜜桃,久久成人影视

VPS參考測評推薦
專注分享VPS主機優(yōu)惠信息
衡天云優(yōu)惠活動
熱網(wǎng)互聯(lián)2026年促銷活動
hostkvm優(yōu)惠促銷活動
zji優(yōu)惠促銷活動
QQGNET優(yōu)惠促銷活動
QQGNET優(yōu)惠促銷活動

簡單地分析了微圖和親子成分中插槽之間的某些通信方法(微型圖的父組成部分將值傳遞給子組件)

主機參考:VPS測評參考推薦/專注分享VPS服務(wù)器優(yōu)惠信息!若您是商家可以在本站進(jìn)行投稿,查看詳情!此外我們還提供軟文收錄、PayPal代付、廣告贊助等服務(wù),查看詳情!
我們發(fā)布的部分優(yōu)惠活動文章可能存在時效性,購買時建議在本站搜索商家名稱可查看相關(guān)文章充分了解該商家!若非中文頁面可使用Edge瀏覽器同步翻譯!PayPal代付/收錄合作

本文介紹了微信迷你計劃中的幾種方法與父子組件之間的交流方式。我希望它對每個人都有幫助!

今天,您是否查看了小插槽和迷你程序的親子組件之間的通信,看看有什么區(qū)別和vue? [相關(guān)學(xué)習(xí)建議:迷你計劃開發(fā)教程]

1。什么是插槽?

自定義組件的WXML結(jié)構(gòu)允許節(jié)點(插槽)托管組件用戶提供的WXML結(jié)構(gòu)

插槽變得更加普遍。這是挖掘兒童組件中孔和填充父部件中孔的過程。 當(dāng)父組件使用子組件時,它確定子組件中的布局。

兒童組件通過在組件標(biāo)簽的中心挖掘內(nèi)容來填充孔。

2。單插槽

applet默認(rèn)情況下僅允許每個自定義組件一個插槽。此限制稱為單個插槽。

默認(rèn)情況下,如果組件中只有一個需要多個插槽的wxml插槽,則可以在組件JS中聲明它以吸引注意力。當(dāng)前,該應(yīng)用程序僅具有默認(rèn)插槽和多個插槽,并且由于時間而不支持示波器插槽。這是代碼(示例):

! - -組件包裝器- -視圖這是視圖組件/視圖的內(nèi)部節(jié)點!組件-組件-標(biāo)簽-名稱! - -內(nèi)容的這一部分位于組件插槽- -視圖上。啟動多個插槽

applet中的自定義組件需要運行插頭對于插槽,代碼是組件的.js文件(示例):

component({選項:{promptleslots:true //如果您啟用了具有選項的多個插槽,則如果您支持組件定義屬性:{/*.../},方法:{//}。區(qū)分不同名稱的不同插槽

代碼為: /view! - -名稱是- -插槽/插槽/View2之后的第二個插槽插槽。親子成分交流

1。父母 - 孩子組件通信方法

屬性綁定用于將數(shù)據(jù)設(shè)置為父組件的指定屬性,允許您僅設(shè)置JSON兼容數(shù)據(jù)(您只能傳遞數(shù)據(jù)而不是方法)

事件綁定用于將數(shù)據(jù)綁定用于將數(shù)據(jù)傳遞給父母組件,并且可以傳遞任何數(shù)據(jù)。 this.SelectComponent()。 Allows direct access to data and methods of child components

2. Attribute bindings

Attribute bindings are used to implement parental pass values ??to children, and can only pass data of normal type, and cannot pass methods to child components

Code is as follows (example):

// Data Node Data of Parent Component: {count: 0 // - test3/my - test3 viewThe nt values ??are: {{{count}}/view

A child component declares the corresponding property of the property node and uses the code as follows (example):

//Child component property properties: {count: number //Wxml structure of child component child component child component child component child component child component child component core implementation procedure

Event binding is used to implement the value passed給父母的孩子,允許您傳遞任何類型的數(shù)據(jù)。 要使用:

在父組件的JS中,定義函數(shù)。此功能以自定義事件的形式傳遞給父部件的WXML子組件。通過自定義事件格式,步驟1中定義的函數(shù)是指子組件JS的子組件。 By calling this.triggerevent('custom event name', {/ *parameter object */}), the data is sent to the js of the parent component of the parent component, and the data passed by the child component is retrieved in e.detail

4. Event Binding Core Implementation Code

Step 1: In the JS parent component in this article, define the functions passed to the child components in the form of custom events.這是代碼(示例):synccount(){console.log('synccount')},第2步:在父組件的wxxml中,請參閱步驟1中定義的函數(shù),以自定義事件的形式將代碼傳遞給子組件,然后將函數(shù)定義的函數(shù)傳遞給子女組件(示例)(示例)(示例):

! - -我的- test3 /我的- test3! -在-或綁定- -我的- test3 /my - test3之后立即協(xié)商自定義事件名稱步驟3:在兒童組件的js中,將數(shù)據(jù)發(fā)送到父級的

代碼如下(示例):

//子一個子組件的wxxml結(jié)構(gòu),計數(shù)值如下:+1})this.triggerevent('triggerevent('sync',sync',{value:properties.chirties.croperties.corperties.corments is and comments js ysements js ysements js ysements js n e js n e js n of js n of js n e js js n:ks of js n:k in of js n:通過e.detail檢索。 Here's the code (example):

synccount(e) {// console.log(e.detail.value) this.setdata({count:count:e.detail.value}

5. Get component instance using select component

selector) You need to get the instance object of the child component and access the data and methods of the child component directly. instance/button getChild(){//點擊按鈕的事件處理功能//請記住,您無法傳遞以下參數(shù):null const child = this.selectComponent('。customa')// ID選擇器#ca child.setdata({count:child.properties.count+1})//您還可以調(diào)用子組件的setData方法。 呢

這幾篇文章你可能也喜歡:

本文由主機參考刊發(fā),轉(zhuǎn)載請注明:簡單地分析了微圖和親子成分中插槽之間的某些通信方法(微型圖的父組成部分將值傳遞給子組件) http://www.k2270.com/146368.html

【騰訊云】領(lǐng)8888元采購禮包,搶爆款云服務(wù)器 每月 9元起,個人開發(fā)者加享折上折!
打賞
轉(zhuǎn)載請注明原文鏈接:主機參考 » 簡單地分析了微圖和親子成分中插槽之間的某些通信方法(微型圖的父組成部分將值傳遞給子組件)
主機參考僅做資料收集,不對商家任何信息及交易做信用擔(dān)保,購買前請注意風(fēng)險,有交易糾紛請自行解決!請查閱:特別聲明

評論 搶沙發(fā)

評論前必須登錄!