提交 c90a175f 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

feat(render function): 补充 render 自定义组件更新 props 示例及测试 issue:11752

上级 b657bfe4
......@@ -2,7 +2,6 @@
<view>
<text class="uni-common-mt bold component-for-h-function">component for h()</text>
<text id="comp-for-h-function-msg">{{msg}}</text>
<slot />
</view>
</template>
......
<template>
<view>
<text class="uni-common-mt bold component-for-h-function">component for h() with slot</text>
<slot />
</view>
</template>
<script setup lang="uts">
import CompForHFunction from '@/components/CompForHFunction.uvue'
import CompForHFunctionWithSlot from '@/components/CompForHFunctionWithSlot.uvue'
const msg = ref('default msg')
// 故意外部声明为UTSJSONObject
const msgProps = { class: 'uni-common-mt msg', style: { color: 'blue' } }
const render = ():VNode => h('view', { class: 'page' }, [
h(CompForHFunction, { msg: msg.value }, (): VNode[] => [h('text', { class: 'comp-slot' }, 'component slot')]),
h(CompForHFunctionWithSlot, {}, () : VNode[] => [h('text', { class: 'comp-slot' }, 'component slot')]),
h(CompForHFunction, { msg: msg.value }),
h('text', msgProps, msg.value),
h(
'button',
......
<script lang="uts">
import CompForHFunction from '@/components/CompForHFunction.uvue'
import CompForHFunctionWithSlot from '@/components/CompForHFunctionWithSlot.uvue'
// 故意外部声明为UTSJSONObject
const msgProps = { class: 'uni-common-mt msg', style: { color: 'blue' } }
export default {
......@@ -10,7 +11,8 @@ export default {
},
render() : VNode {
return h('view', { class: 'page' }, [
h(CompForHFunction, { msg: this.msg }, () : VNode[] => [h('text', { class: 'comp-slot' }, 'component slot')]),
h(CompForHFunctionWithSlot, {}, () : VNode[] => [h('text', { class: 'comp-slot' }, 'component slot')]),
h(CompForHFunction, { msg: this.msg }),
h('text', msgProps, this.msg),
h(
'button',
......
......@@ -18,7 +18,7 @@ describe('render-function render', () => {
const ComForRenderFunction = await page.$('.component-for-h-function')
expect(await ComForRenderFunction.text()).toEqual(
'component for h()'
'component for h() with slot'
)
const compSlot = await page.$('.comp-slot')
expect(await compSlot.text()).toEqual('component slot')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册