W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
用于監(jiān)聽(tīng)用戶發(fā)起的主動(dòng)截屏事件,可以接收到系統(tǒng)以及第三方截屏工具的截屏事件通知??墒褂?my.offUserCaptureScreen() 取消監(jiān)聽(tīng)。
<!-- API-DEMO page/API/user-capture-screen/user-capture-screen.axml-->
<view class="page">
<view class="page-description">用戶截屏事件 API</view>
<view class="page-section">
<view class="page-section-title">my.onUserCaptureScreen</view>
<view class="page-section-demo">
<view>目前狀態(tài):{{ condition ? "已經(jīng)開(kāi)啟監(jiān)聽(tīng)" : '已經(jīng)取消監(jiān)聽(tīng)' }}</view>
<view a:if="{{condition}}">
<button type="primary" onTap="offUserCaptureScreen">取消監(jiān)聽(tīng)屏幕事件</button>
</view>
<view a:else>
<button type="primary" onTap="onUserCaptureScreen">開(kāi)啟監(jiān)聽(tīng)屏幕事件</button>
</view>
</view>
</view>
</view>
// API-DEMO page/API/user-capture-screen/user-capture-screen.js
Page({
data: {
condition: false,
},
onReady() {
my.onUserCaptureScreen(() => {
my.alert({
content: '收到用戶截圖',
});
});
},
offUserCaptureScreen() {
my.offUserCaptureScreen();
this.setData({
condition: false,
});
},
onUserCaptureScreen() {
my.onUserCaptureScreen(() => {
my.alert({
content: '收到用戶截圖'
});
});
this.setData({
condition: true,
});
},
});
取消監(jiān)聽(tīng)截屏事件。
<!-- API-DEMO page/API/user-capture-screen/user-capture-screen.axml-->
<view class="page">
<view class="page-description">用戶截屏事件 API</view>
<view class="page-section">
<view class="page-section-title">my.onUserCaptureScreen</view>
<view class="page-section-demo">
<view>目前狀態(tài):{{ condition ? "已經(jīng)開(kāi)啟監(jiān)聽(tīng)" : '已經(jīng)取消監(jiān)聽(tīng)' }}</view>
<view a:if="{{condition}}">
<button type="primary" onTap="offUserCaptureScreen">取消監(jiān)聽(tīng)屏幕事件</button>
</view>
<view a:else>
<button type="primary" onTap="onUserCaptureScreen">開(kāi)啟監(jiān)聽(tīng)屏幕事件</button>
</view>
</view>
</view>
</view>
// API-DEMO page/API/user-capture-screen/user-capture-screen.js
Page({
data: {
condition: false,
},
onReady() {
my.onUserCaptureScreen(() => {
my.alert({
content: '收到用戶截圖',
});
});
},
offUserCaptureScreen() {
my.offUserCaptureScreen();
this.setData({
condition: false,
});
},
onUserCaptureScreen() {
my.onUserCaptureScreen(() => {
my.alert({
content: '收到用戶截圖'
});
});
this.setData({
condition: true,
});
},
});
my.offUserCaptureScreen();
my.offUserCaptureScreen(this.callback);
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: