cloneVNode-composition.uvue 668 字节
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
<script setup lang="uts">
  defineOptions({
    render() : VNode {
      const originalVNode = h('view', { class: 'original' }, [
        h('text', {}, 'Hello World'),
      ])
      // #ifdef APP
      const clonedVNode = cloneVNode(originalVNode, new Map<string, any | null>([['class', 'cloned']]))
      // #endif
      // #ifdef WEB
      const clonedVNode = cloneVNode(originalVNode, { class: 'cloned'})
      // #endif

      return h('view', { class: 'flex flex-col' }, [originalVNode, clonedVNode])
    }
  })
</script>

<style>
  .original {
    background-color: #ff0000;
  }

  .cloned {
    background-color: #00ff00;
  }
</style>