The actionsheet @wines
@wines/actionsheet从底部弹出的模态框,提供和当前场景相关的操作菜单。
``json`
{
"navigationBarTitleText": "ActionSheet",
"usingComponents": {
"wux-button": "@wines/button",
"wux-actionsheet": "@wines/actionsheet"
}
}
`ts
import './index.less';
import { $wuxActionSheet } from '@wines/actionsheet';
Page({
data: {},
onLoad() {
/* /
},
showActionSheet1() {
void wx.showActionSheet({
itemList: ['实例菜单', '实例菜单'],
});
},
timeout: 0 as number,
showActionSheet3() {
if (this.timeout) clearTimeout(this.timeout);
const hideSheet = $wuxActionSheet().showSheet({
titleText: '三秒后自动关闭',
buttons: [
{
text: '实例菜单',
},
{
text: '实例菜单',
},
],
buttonClicked() {
return true;
},
});
this.timeout = setTimeout(() => {
hideSheet();
}, 3000);
},
});
`
> 该组件主要依靠 JavaScript 主动调用,所以一般只需在 wxml 中添加一个组件,并设置 id 为 #wux-actionsheet 或其他,之后在 page.js 中调用 $wuxActionSheet(this, id) 获取匹配到的第一个组件实例对象。
`xml
`
| 参数 | 类型 | 描述 | 默认值 |
| -------------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------- | -------------------------------- |
| options | object | 配置项 | - |string
| options.prefixCls | | 自定义类名前缀 | wux-actionsheet |string
| options.titleText | | 标题 | - |array
| options.buttons | | 按钮 | [] |string
| options.buttons[].text | | 按钮的文本 | - |string
| options.buttons[].icon | | 按钮的图标 | - |boolean
| options.buttons[].disabled | | 是否禁用 | false |string
| options.buttons[].openType | | 微信开放能力,可选值为 contact、share、getUserInfo、getPhoneNumber、launchApp、openSetting、feedback | - |string
| options.buttons[].hoverClass | | 指定按下去的样式类。当 hover-class="none" 时,没有点击态效果 | wux-actionsheet\_\_button--hover |boolean
| options.buttons[].hoverStopPropagation | | 指定是否阻止本节点的祖先节点出现点击态 | false |number
| options.buttons[].hoverStartTime | | 按住后多久出现点击态,单位毫秒 | 20 |number
| options.buttons[].hoverStayTime | | 手指松开后点击态保留时间,单位毫秒 | 70 |string
| options.buttons[].lang | | 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。 | en |string
| options.buttons[].sessionFrom | | 会话来源 | - |string
| options.buttons[].sendMessageTitle | | 会话内消息卡片标题 | 当前标题 |string
| options.buttons[].sendMessagePath | | 会话内消息卡片点击跳转小程序路径 | 当前分享路径 |string
| options.buttons[].sendMessageImg | | 会话内消息卡片图片 | 截图 |boolean
| options.buttons[].showMessageCard | | 显示会话内消息卡片 | false |string
| options.buttons[].appParameter | | 打开 APP 时,向 APP 传递的参数 | - |function
| bind:getuserinfo | | 用户点击该按钮时,会返回获取到的用户信息,回调的detail数据与wx.getUserInfo返回的一致 | - |function
| bind:contact | | 客服消息回调 | - |function
| bind:getphonenumber | | 获取用户手机号回调 | - |function
| bind:error | | 当使用开放能力时,发生错误的回调 | - |function
| bind:opensetting | | 在打开授权设置页后回调 | - |function
| options.buttonClicked | | 按钮点击事件,返回值为 true 时将会关闭组件 | - |string
| options.cancelText | | 取消按钮的文本 | 取消 |function
| options.cancel | | 取消按钮或蒙层点击事件 | - |string
| options.destructiveText | | 删除按钮的文本 | - |function
| options.destructiveButtonClicked | | 删除按钮点击事件 | - |
> 更多参数说明请参考微信官方的表单组件 Button。
- ActionSheet.showSheet
- ActionSheet.removeSheet
- ActionSheet.cancel
> ActionSheet.showSheet 函数调用后,会返回一个引用,可以通过该引用手动关闭组件
```
const hide = ActionSheet.showSheet()
hide()