Home >WeChat Applet >Mini Program Development >Detailed explanation and example code of WeChat mini program action-sheet

Detailed explanation and example code of WeChat mini program action-sheet

高洛峰
高洛峰Original
2018-05-25 16:32:283054browse

This article mainly introduces the detailed explanation and example code of WeChat Mini Program action-sheet. Friends in need can refer to it

WeChat Mini Program action-sheet

Attribute name Type Default value Description
hidden Boolean true Whether to hide
bindchange EventHandle The change event is triggered when the background or action-sheet-cancel button is clicked, and does not carry data

##action-sheet-item

Sub-options of the bottom menu table.


action-sheet-cancel

The difference between the cancel button of the bottom menu sheet and action-sheet-item is that clicking it will trigger action-sheet change event, and will appear to be spaced apart from the content above it.


Sample code:

<button type="default" bindtap="actionSheetTap">弹出action sheet</button>
<action-sheet hidden="{{actionSheetHidden}}" bindchange="actionSheetChange">
 <block wx:for-items="{{actionSheetItems}}">
 <action-sheet-item class="item" bindtap="bind{{item}}">{{item}}</action-sheet-item>
 </block>
 <action-sheet-cancel class="cancel">取消</action-sheet-cancel>
</action-sheet>
var items = [&#39;item1&#39;, &#39;item2&#39;, &#39;item3&#39;, &#39;item4&#39;]
var pageObject = {
 data: {
 actionSheetHidden: true,
 actionSheetItems: items
 },
 actionSheetTap: function(e) {
 this.setData({
 actionSheetHidden: !this.data.actionSheetHidden
 })
 },
 actionSheetChange: function(e) {
 this.setData({
 actionSheetHidden: !this.data.actionSheetHidden
 })
 }
}

for (var i = 0; i < items.length; ++i) {
 (function(itemName) {
 pageObject[&#39;bind&#39; + itemName] = function(e) {
 console.log(&#39;click&#39; + itemName, e)
 }
 })(items[i])
}

Page(pageObject)
action-sheet

微信小程序  action-sheet详解及实例代码

Thank you for reading, I hope it can help everyone, thank you for your support of this site!

For more WeChat applet action-sheet detailed explanations and example code related articles, please pay attention to the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn