小程式自定義元件的兩種方式

2022-08-09 05:33:10 字數 1903 閱讀 5167

一:!(通過定義id,採取selectcomponent選擇呼叫)

component

wxml:

<

view

class

='wx_dialog_container'

hidden

="}"

>

<

view

class

='wx-mask'

>

view

>

<

view

class

='wx-dialog'

>

<

view

class

='wx-dialog-title'

>}

view

>

<

view

class

='wx-dialog-content'

>}

view

>

<

view

class

='wx-dialog-footer'

>

<

view

class

='wx-dialog-btn'

catchtap

='_cancelevent'

>}

view

>

<

view

class

='wx-dialog-btn'

catchtap

='_confirmevent'

>}

view

>

view

>

view

>

view

>

js:

component(,

/** * 元件的屬性列表

*/properties: ,

//彈窗內容

content: ,

//彈窗取消按鈕文字

canceltext: ,

//彈窗確認按鈕文字

confirmtext: ,

//是否顯示dialog

isshown:

},/*

* * 私有資料,元件的初始資料

* 元件的初始資料

*/data: ,

/** * 元件的方法列表**/

methods: ,

_confirmevent()

}})

page引用:

wxml:

<

dialog

title

='新的啟航'

content

='啟航個啥,站住!'

canceltext

='取消'

confirm

='確定'

isshown

="}"

bind:cancelevent

="cancel"

bind:confirmevent

="confirm"

/>

<

button

type

="primary"

bindtap

="showdialog"

> clickme!

button

>

js:

data: ,

showdialog() )

},cancel(e) )

},confirm(e) )

},

json

}

-----selectcomponent方法後期補充

自定義dialog的兩種方式

介紹自定義對話方塊 dialog 的兩種方式 方式一 首先自定義乙個自己想要設計的對話方塊的介面布局,我的是這樣的 然後在activity類中進行展示,這裡我寫了乙個showinputpwddialog方法 輸入密碼對話方塊 private void showinputpwddialog 方式二 可...

自定義異常的兩種方式

自定義異常的兩種方式 一 丟擲異常 def greet name,city if notisinstance name,str raise typeerror name must be str if notisinstance city,str raise typeerror age must be...

自定義View的兩種方式

一 xib自定義view 1.思路 2.關鍵 1 import23 class45 inte ce67 8 模型資料9 1113 14 15 通過模型資料來建立乙個view 16 1819 end 1 import 2 import 34 inte ce 5 property weak,nonato...