render-composition.uvue 771 字节
Newer Older
1
<script setup lang="uts">
DCloud-WZF's avatar
DCloud-WZF 已提交
2
import CompForHFunction from '@/components/CompForHFunction.uvue'
3 4

defineOptions({
D
DCloud_LXH 已提交
5
  data() {
DCloud-WZF's avatar
DCloud-WZF 已提交
6 7 8 9 10
    return {
      msg: 'default msg'
    }
  },
  render(): VNode {
11 12
    const instance = getCurrentInstance()!.proxy!
    
D
DCloud_LXH 已提交
13
    return h('view', { class: 'page' }, [
DCloud-WZF's avatar
DCloud-WZF 已提交
14
      h(CompForHFunction, {}, (): VNode[] => [h('text', { class: 'comp-slot' }, 'component slot')]),
15
      h('text', { class: 'uni-common-mt msg', style: { color: 'blue' } }, instance.$data['msg']),
D
DCloud_LXH 已提交
16 17 18 19 20 21
      h(
        'button',
        {
          class: 'uni-common-mt btn',
          type: 'primary',
          onClick: () => {
22
            instance.$data['msg'] = 'new msg'
D
DCloud_LXH 已提交
23 24 25 26
          }
        },
        'click'
      )
DCloud-WZF's avatar
DCloud-WZF 已提交
27 28
    ])
  }
29
})
DCloud-WZF's avatar
DCloud-WZF 已提交
30 31
</script>

DCloud-WZF's avatar
DCloud-WZF 已提交
32
<style>
DCloud-WZF's avatar
DCloud-WZF 已提交
33 34 35
.btn {
  color: red;
}
D
DCloud_LXH 已提交
36
</style>