uniapp有时真机或打包h5 ,接入其余客户端中只是查看接收参数等异常时。
也可以不用抓包直接放入 app.vue 中 options.query之类直接弹窗,复制出查看
uni.showModal({
title: 'url原始数据',
content: JSON.stringify(options.query) || '',
success: res => {
if (!document.queryCommandSupported('copy')) {
uni.showToast({
title: '浏览器不支持',
icon: 'none'
})
return
}
let textarea = document.createElement('textarea')
textarea.value = 要复制文本
textarea.readOnly = 'readOnly'
document.body.appendChild(textarea)
textarea.select() // 选择对象
textarea.setSelectionRange(0, 要复制文本.length) //核心
let result = document.execCommand('copy') // 执行浏览器复制命令
if (result) {
uni.showToast({
title: '复制成功!',
icon: 'none'
})
}
textarea.remove()
}
})
网友评论