EffectCameraStream.offRequest
收藏
我的收藏

基础库 2.19.0 开始支持本方法,低版本需做兼容处理。​
取消监听相机资源请求事件,取消后 EffectCameraStream.onRequest 的回调参数将不被触发。​

语法​

EffectCameraStream.offRequest(callback)

参数说明​

function callback​

回调参数​

无​

代码示例​

预期表现:点击按钮后看不到弹窗提示。​
<button type="primary" bindtap="requestEffectCamera">打开相机</button>
Page({ onShow: function (options) { this.effectCameraStream = tt.createEffectCameraStream(this); this.effectCameraStream.onError(this.onError); this.effectCameraStream.onRequest(this.onRequest); this.effectCameraStream.offRequest(this.onRequest); }, requestEffectCamera() { this.effectCameraStream.request({ orientation: "front", }); }, onError(error) { console.log("onError", error); const { type, errMsg } = error; tt.showModal({ title: `onError ${type}`, content: errMsg, }); }, onRequest() { tt.showToast({ title: "相机资源申请成功", // 内容 }); }, });

Bug & Tip​

暂无。​