直接将代码扔到app.js里
Taro.onUserCaptureScreen(function (res) {
console.log('用户截屏了')
// 获取当前页面路径
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
const currentPath = `/${currentPage.route}`
console.log('当前页面路径:pages', pages)
console.log('当前页面路径:', currentPath)
})
原生微信小程序API也可以
wx.onUserCaptureScreen(function (res) {
console.log('用户截屏了 wx')
})
注意 原生优先级高于taro