文本复制到剪切板
技术栈:vue + h5
scene
: 点击购买弹出弹框,复制弹框内容到剪切板。点粘贴可自动填充到输入框
/**
* 选中 兼容ios与android
* @param txtBox 文本Dom
* @param startIndex 起始下标
* @param endIndex 结束下标
*/
const selectText = (txtBox, startIndex, endIndex) => {
if (txtBox.createTextRange) {
//ie
const textRange = txtBox.createTextRange();
textRange.collapse(true);
textRange