美文网首页univue系列
uniapp 调试参数输出 复制出查看代码

uniapp 调试参数输出 复制出查看代码

作者: litielongxx | 来源:发表于2023-07-04 10:08 被阅读0次

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()
        }
      })

相关文章

网友评论

    本文标题:uniapp 调试参数输出 复制出查看代码

    本文链接:https://www.haomeiwen.com/subject/epocudtx.html