swan.closeCommunityEditor
解释: 关闭原生全屏内容发布器
方法参数
Object object
emojiPath 参数说明
示例
在开发者工具中预览效果
扫码体验
请使用百度APP扫码
图片示例
代码示例
-
<view class="wrap"> <view class="card-area"> <view class="top-description border-bottom"> <view>原帖标题</view> <view>{{content}}</view> </view> <button type="primary" bindtap="openCommunityEditor">点击回复原帖</button> </view></view>
-
Page({ data: { content: '原帖内容' }, onLoad(e) { }, openCommunityEditor() { swan.openCommunityEditor({ contentPlaceholder: '请输入帖子正文', titlePlaceholder: '请输入标题', moduleList: ['title', 'image', 'emoji', 'target'], imageConf: { maxNum: 9, ratio: 1 }, navBarTitleText: '发布帖子', navBarTextStyle: 'black', navBarBackgroundColor: '#ffffff', confirmText: '发布', confirmColor: '#3388ff', cancelText: '取消', cancelColor: '#666666', targetText: '话题/吧/版块', emojiPath: '../../emojidata', success: function (res) { console.log('openCommunityEditor success', res); // 将图片上传到服务器 // swan.uploadFile({ // url: 'https://smartprogram.baidu.com/xxx', // 仅为示例,并非真实的接口地址 // filePath: res.tempFilePaths[0], // 要上传文件资源的路径 // name: 'myfile', // success: function (res) { // console.log(res.statusCode); // // 上传成功关闭发布器 // swan.closeCommunityEditor(); // }, // fail: function (err) { // console.log('错误码:' + err.errCode); // console.log('错误信息:' + err.errMsg); // } // }); swan.closeCommunityEditor(); swan.showToast({ title: '发布成功', icon: 'none' }); }, fail: function (err) { console.log('openCommunityEditor fail', err); swan.closeCommunityEditor(); }, complete: function (res) { console.log('openCommunityEditor complete', res); } }); // 定时器模拟开发者的提示时机,真实时机可据业务场景触发 let that = this; setTimeout(function () { swan.showModal({ title: '更新提示', content: '您所评论的内容有更新,是否要回到原帖查看', success(res) { console.log(res) if (res.confirm) { swan.closeCommunityEditor(); that.setData('content', '更新的内容') } else if(res.cancel) { console.log('用户点击了取消'); } } }); }, 5000); }});
