3D彩票网

WEIXIANGHUDONGZHUYING:MEITIGUANGGAO(PENGYOUQUANGUANGGAO,TENGXUNGUANGDIANTONG,TENGXUNXINWENAPP,XINLANGXINWENAPP,FENGHUANGXINWENAPP,YOUKUSHIPIN,MOMODAODIANTONG)、ZHONGQINGWANGZHANJIANSHE、ZHONGQINGXIAOCHENGXUKAIFA、ZHONGQINGGONGZHONGHAOZHIZUO

全国服务热线:15320293856

ERWEIMA

DIANHUA

汪经理:13594363214

文经理:17783139095

罗经理:15320293856

信息搜索
您当前所在的位置 3D彩票网 > 微享资讯 > 小程序 >

小程序自定义组件如何减少重复开发

来源: 微享互动3D彩票网      时间:2018-07-26 15:39:39  

  JIAOWEIFUZADEXIAOCHENGXUZHONGCHANGCHANGHUIYOUYIXIETONGYONGDEJIAOHUMOKUAI,BIRU“XIALAXUANZELIEBIAO”、“SOUSUOKUANG”、“RIQIXUANZEQI”DENG。ZHEIXIEJIEMIANJIAOHUMOKUAIKENENGHUIZAIDUOGEYEMIANZHONGYONGDAO,LUOJIYEXIANGDUIDULI。RANER,YONGCHUANTONGDEXIAOCHENGXUKAIFAFANGFALAISHIXIANZHEIYANGDEMOKUAISHIFEICHANGFANSUODE。XIAOCHENGXUDEJIEMIANSHIYOUYIXILIEZUJIANGOUCHENGDE。XIAOCHENGXUJICHUKUTIGONGLEYIZUJICHUZUJIANLAIMANZUKAIFAZHEDEJIBENXUQIU。DANSUIZHEXIAOCHENGXUKAIFABIANDEYUELAIYUEFUZA,DANCHUNSHIYONGJICHUZUJIANLAIJINXINGKAIFAYEBIANDEYUELAIYUEBUFANGBIAN。

  MIANDUIZHEIGEQINGKUANG,XIAOCHENGXUJICHUKUTIGONGLERANGKAIFAZHEZIJICHUANGJIANJIEMIANZUJIANDETEXINGDE“ZIDINGYIZUJIAN”。TONGGUOZHEIGETEXING,KAIFAZHEJIUNENGGOUJIANGZHEIYANGDEJIAOHUMOKUAICHOUXIANGCHENGJIEMIANZUJIAN,SHIJIEMIANDAIMAZUZHIBIANDEFEICHANGLINGHUO。ZIDINGYIZUJIANSHIXIANGDUIDULIDEGONGNENGMOKUAI,KAIFAZHEKEYIJIANGZIJIDEZIDINGYIZUJIANDAIMAKAIYUANCHULAI,YUQITAKAIFAZHEGONGXIANGKAIFACHENGGUO。ZIDINGYIZUJIANJUBUGENGXINSHIDEXINGNENGXIANGBIYEMIANDEJUBUGENGXINYAOXIAOHENDUO,ZAIBIYAOSHIKEYILIYONGZHEIGETEDIANJINXINGXINGNENGYOUHUA。KAIFAZHEKEYIJIANGYIXIEFUYONGXINGQIANGDEDAIMACHOUXIANGCHENGZIDINGYIZUJIAN,TAMENDESHIYONGFANGFAYUJICHUKUNEIZHIDEview 、 buttonDENGJICHUZUJIANFEICHANGXIANGSI。ZHEIYANGDEZUJIANHUAFEICHANGYOULIYUDAIMALUOJIDEJIEOUHE。

  如何编写一个自定义组件?

  MEIGEZIDINGYIZUJIANYOUSIGEDAIMAWENJIANZUCHENG:jsonWENJIANYONGYUYUFANGZHIYIXIEZUIJIBENDEZUJIANPEIZHI,wxmlWENJIANZUJIANMOBAN, wxss WENJIANZUJIANDEYANGSHI,ZHIZAIZUJIANNEIBUJIEDIANSHANGSHENGXIAO(ZHEIGEWENJIANSHIKEXUANDE),js WENJIANZUJIANDE JS DAIMA,CHENGZAIZUJIANDEZHUYAOLUOJI。ZHEISIGEWENJIANYUBIANXIEYIGEYEMIANSHIYONGDAODESIGEWENJIANFEICHANGLEISI,DANYEYOUQUBIE。XIAMIANJIANGJIESHAORUHELIYONGZHEISIGEWENJIANBIANXIEYIGEJIANDANDEZIDINGYIZUJIAN。

  1.组件配置

  BIANXIEYIGEZIDINGYIZUJIAN,SHOUXIANYINGZAIXIAOCHENGXUDAIMAMULUZHONGHESHIDEWEIZHICHUANGJIANYIGE json WENJIAN。ZHEILIWOMENBAWENJIANFANGZHIZAIXIAOCHENGXUDE componentsMULUXIA,MINGWEI custom-checkbox.json 。

小程序自定义组件减少重复开发方法

  ZHEIGEWENJIANZHONGBAOHANYIXIANEIRONG:

  {

  component:ture

  }

  2.组件模板

  ZAITONGYIMULUXIA,CHUANGJIANYIGEMOBANWENJIAN custom-checkbox.wxml 。ZHEIGEWENJIANDEXIEFAYUYEMIANMOBANHENLEISI:

小程序自定义组件减少重复开发方法

  ZHEIGEMOBANJIANGZAIZUJIANZHONGXUANRANCHUYIGE checkbox HEYIGE label 。

  3.组件样式

  TONGYANGLEISIYUYEMIAN, wxss WENJIANZHONGKEYIZHIDINGZUJIANJIEDIANDEYANGSHI。QIZHONGDEYANGSHIJINZAIZUJIANNEIBUSHENGXIAO。XUYAOZHUYIDESHI,YANGSHIZHINENGTONGGUOLEIXUANZEQI(RU .the-class-name )LAIZHIDING:

小程序自定义组件减少重复开发方法

  4.ZUJIANDINGYI

3D彩票网  ZUJIANDE JS WENJIANZHONGBIXUBAOHANZUJIANDINGYI。DINGYISHISHIYONG Component GOUZAOQI:

小程序自定义组件减少重复开发方法

  JIANDANDE Component GOUZAOQIDIAOYONGBAOHAN3GEDINGYIDUAN:methods ZHONGDEFANGFAKEYIYONGLAIBAOHANZUJIANDESHIJIANHUIDIAOHANSHU;data SHIZUJIANDENEIBUSHUJU,KEYIYONG this.setData FANGFALAIGAIBIAN;properties ZHONGSHENGMINGZHEIGEZUJIANDESHUXING,SHANGLIZHONGSHENGMINGLE title SHUXING,ZHEIYANG,ZUJIANWAIBUZAISHIYONGZUJIANSHIJIUKEYIZHIDINGZHEIGESHUXINGDEZHI。

3D彩票网  ZHEIYANGWOMENJIUBIANXIEHAOLE custom-checkbox ZHEIGEZUJIAN。

  如何使用自定义组件?

3D彩票网  ZAIXUYAOSHIYONGZHEIGEZUJIANDEYEMIANSUODUIYINGDE json WENJIANZHONG,TIANJIAXIAMIANDEZIDINGYIZUJIANSHENGMING:

小程序自定义组件减少重复开发方法

  ZAIYEMIANDUIYINGDE wxml WENJIANZHONGSHIYONGLE:ZAIZIDINGYIZUJIANZHONGYESHIKEYIYINYONGQITAZIDINGYIZUJIANDE,FANGFAYUZAIYEMIANZHONGYINYONGDEFANGFALEISI。

  高级特性与注意事项

  CHULESHANGSHUDEJIBENGONGNENGWAI,ZIDINGYIZUJIANHAITIGONGLEYIZUJICHUJIEKOU,YONGLAISHIXIANGEZHONGGEYANGDEGONGNENG。RUGUOSHIJIANJIZHIHAIBUZUYIMANZUZUJIANJIANTONGXINXUYAODEHUA,KEYISHIYONGselectComponentJIEKOU。RUGUOTONGSHIJIANLILEHAOJIGEYOUXIANGHUGUANLIANGUANXIDEZUJIAN,KEYISHIYONGZUJIANJIANGUANXIJIEKOUrelations。ZUJIANJIANKENENGXUYAOGONGXIANGBUFENDAIMA,ZHEISHIKEYISHIYONGbehaviors。ZAIYEMIANHEZIDINGYIZUJIANJIANTONGXINSHI,ZUICHANGYONGDEFANGFASHISHIJIANJIZHI,ZIDINGYIZUJIANKEYISHIYONG triggerEventJIEKOUXIANGYEMIANFASONGSHIJIAN,YEMIAN WXML ZHONGSHIYONG bind HUOZHE catch JIUKEYIJIANTINGDAO。

 

来源:重庆网站建设,本文网址:http://md1166.com/app-news/761.html,欢迎分享,(电话:15320293856,微信:llhhldancing)

预约咨询

MASHANGTIJIAONINDEXUQIU,WOMENHUIZAI24XIAOSHINEILIANXININ,TIGONGCHANPINCEHUAFUWU!

3D彩票网WANGZHI:http://md1166.com

DIZHI:ZHONGQINGSHILIANGJIANGXINQUTIANWANGXINGC1DONG3LOU

3D彩票网WANGZHANJIANSHEZIXUN:15320293856 LUOJINGLI

PENGYOUQUANGUANGGAOZIXUN:17783139095 WENJINGLI

WEIXIANGGUANFANGWEIXIN

SAOYISAO GUANZHUGONGZHONGHAO