求教查询页面,复制按钮,只能复制上面的div内容,下面的如何复制???拜托了。。。。。。
function copyArticle(event) {
const range = document.createRange();
range.selectNode(document.getElementById('content'));
const selection = window.getSelection();
if(selection.rangeCount > 0) selection.removeAllRanges();
selection.addRange(range);
document.execCommand('copy');
alert("复制【法定代表】成功!");
}

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
浅拷贝:使用`Object.assign()`或展开运算符`...`来复制对象,使用`Array.from()`或展开运算符`...`来复制数组。例如:
let obj1 = { name: 'Alice', age: 20 }; let obj2 = Object.assign({}, obj1); // 浅拷贝对象 console.log(obj2); // 输出{ name: 'Alice', age: 20 } let arr1 = [1, 2, 3]; let arr2 = [...arr1]; // 浅拷贝数组 console.log(arr2); // 输出[1, 2, 3]-深拷贝:使用`JSON.parse()`和`JSON.stringify()`来实现深拷贝。例如:
let obj1 = { name: 'Alice', age: 20 }; let obj2 = JSON.parse(JSON.stringify(obj1)); // 深拷贝对象 console.log(obj2); // 输出{ name: 'Alice', age: 20 } let arr1 = [1, 2, [3, 4]]; let arr2 = JSON.parse(JSON.stringify(arr1)); // 深拷贝数组 console.log(arr2); // 输出[1, 2, [3, 4]]