工作日记记录-vue组件视图切换

44 阅读1分钟

第一步:在父组件中获取两个组件外的dom

第二步:在获取的dom中获取firstChild,然后进行appendChild

    const switchView = (index:number)=>{
          const switchView = (index:number)=>{
          const show = document.getElementById(`show${index}`)
          const bigBox= document.getElementById('bigBox')
          const showView:any = show?.firstChild
          const bigShow:any = bigBox?.firstChild
          show?.appendChild(bigShow)
          bigBox?.appendChild(showView)
    }