求教查詢頁面,複製按鈕,只能複製上面的div內(nèi)容,下面的如何複製? ? ?拜託了。 。 。 。 。 。
<script>
? ? ? function copyArticle(event) {
? ? ?? const range =
? ? ?? const range =
? ? ? ? range.selectNode(document.getElementById('content'));
################################## ######## ? ? ? ? const selection = window.getSelection();############### ? ? ? ? if(selection.rangeCount > 0) selection.removeAllRanges(removeAllRanges(); ############ ? ? ? ? selection.addRange(range);############### ? ? ? ? document.execCommand('copy');####### ######## ? ? ? ? alert("複製【法定代表】成功!");############### ? ? ? }######</script>### #############<div class="col-md-6 footer-grid">######<h4? class="footer-head">統(tǒng)一社會信用代碼:<span id="content">{$art.tyshdm}</span></h4>######? ? <ul>######? ? ? ? <li><li><li> ;p style="text-indent: -5em;margin-left: 5em">名? ? 稱為:<span id="content1">{$art.gsname}</span>###### </li>######? ? ? ? <li><p style="text-indent: -5em;margin-left: 5em">類? ? 別:{$art.jylb}##### #</li>######? ? ? ? <li><p style="text-indent: -5em;margin-left: 5em">法定代表:{$art.fddbr}##### ##</li>######? ? ? ? <li><p style="text-indent: -5em;margin-left: 5em">經(jīng)營範(fàn)圍:{$art.jyfw}### ###</li> ######? ? </ul>###### </div>
<div class="col-md-6 footer-grid">
<h4 class="footer-head"> </h4>
? ? <ul>
? ? ? ? <li><p style="text-indent: -5em;margin-left: 5em">成立日期:{$art.clrq}
</li>
? ? ? ? <li><p style="text-indent: -5em;margin-left: 5em">核準(zhǔn)日期:{$art.hzrq}
</li>
? ? ? ? <li><p style="text-indent: -5em;margin-left: 5em">登錄機(jī)關(guān):{$art.djjg }
</li>
? ? ? ? <li><p style="text-indent: -5em;margin-left: 5em">經(jīng)營場所:<span id ="content3">{$art.jycs}</span>
#</li>
淺拷貝:使用`Object.assign()`或展開運(yùn)算子`...`來複製對象,使用`Array.from()`或展開運(yùn)算子`...`來複製數(shù)組。例如:
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];?//?淺拷貝數(shù)組 console.log(arr2);?//?輸出[1,?2,?3]
-深拷貝:使用`JSON.parse()`和`JSON.stringify()`來實(shí)現(xiàn)深拷貝。例如:
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));?//?深拷貝數(shù)組 console.log(arr2);?//?輸出[1,?2,?[3,?4]]