微信小程序----wx.showActionSheet(OBJECT)操作菜单(MUI操作表)
2018-01-04 14:19
676 查看
DEMO下载
利用wx.chooseVideo录制视频;
利用wx.chooseImage选取本地图片;
利用wx.previewImage进行图片预览。
更多微信小程序实例
效果图
实现
利用了微信小程序的wx.showActionSheet(OBJECT)操作菜单API实现菜单操作;利用wx.chooseVideo录制视频;
利用wx.chooseImage选取本地图片;
利用wx.previewImage进行图片预览。
WXML
<view class="tui-content"> <view class="tui-show-name"> <text class="tui-card-btn" bindtap="openActionsheet">打开actionsheet</text> </view> </view> <view class="tui-fixed-foot"> <text class="tui-card-btn tui-fl" bindtap="openActionsheetDe">DELETE</text> <text class="tui-card-btn tui-fr" bindtap="openActionsheetSh">SHARE</text> </view>
JS
Page({ data: { }, openActionsheet(){ wx.showActionSheet({ itemList: ['拍照或录像','选取现有的'], itemColor: '#007aff', success(res){ console.log(res.tapIndex); if (res.tapIndex === 0){ wx.chooseVideo({ sourceType: ['camera'], success(res){ console.log(res.tempFilePath); } }) }else if (res.tapIndex === 1){ wx.chooseImage({ count: 3, // 设置最多三张 sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success (res) { var tempFilePaths = res.tempFilePaths; // 图片预览 wx.previewImage({ current: res.tempFilePaths[0], urls: res.tempFilePaths }) } }) } } }) }, openActionsheetDe(e){ wx.showActionSheet({ itemList: ['删除信息'], itemColor: '#FF3B30', success(res){ wx.showToast({title: '删除成功!'}) } }) }, openActionsheetSh(e){ wx.showActionSheet({ itemList: ['回复','转发','打印'], itemColor: '#007aff', success(res) { if(res.tapIndex === 0){ wx.showToast({ title: '回复成功!' }); }else if(res.tapIndex === 1){ wx.showToast({ title: '转发成功!' }); }else if(res.tapIndex === 2){ wx.showToast({ title: '打印成功!' }); } } }) } })
注意
wx.chooseVideo录制视频API必须采用预览微信小程序的模式才能调用!更多微信小程序实例
相关文章推荐
- 微信小程序----界面交互反馈API(wx.showToast(OBJECT)、wx.showModal(OBJECT))(MUI消息框)
- 微信小程序 action-sheet底部菜单详解
- 微信小程序开发之——wx.showToast(OBJECT)的使用
- 微信小程序例子——使用action-sheet弹出小程序底部菜单
- 小程序API:wx.showActionSheet 将 itemList动态赋值
- 微信小程序实现action-sheet弹出底部菜单功能【附源码下载】
- 微信小程序 action-sheet 反馈上拉菜单简单实例
- 微信小程序 action-sheet 反馈上拉菜单
- 微信小程序--官方文档补充【操作反馈】--action-sheet组件
- 微信小程序把玩(三十一)wx.uploadFile(object), wx.downloadFile(object) API
- 微信小程序(二十二)action-sheet组件详细介绍
- 微信小程序的网络设置,及网络请求:wx.request(OBJECT)
- 微信小程序 action-sheet详解及实例代码
- 微信小程序弹出操作菜单
- 微信小程序 wx.showToast()
- 微信小程序的网络设置,及网络请求:wx.request(OBJECT)
- 微信小程序 wx.request(OBJECT)发起请求详解
- 微信小程序把玩(三十)wx.request(object) API
- 微信小程序 wx.uploadFile(object), wx.downloadFile(object) API