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

refactor(render function): render

上级 d507a19b
......@@ -976,20 +976,20 @@ export default {
{
id: 'render',
name: 'render & h()',
children: [
{
id: 'render-options',
name: 'render 选项式 API',
url: 'render-options'
},
{
id: 'render-composition',
name: 'render 组合式 API',
// #ifdef APP-IOS
enable: false,
// #endif
url: 'render-composition'
},
children: [
{
id: 'render-options',
name: 'render 选项式 API',
url: 'render-options'
},
{
id: 'render-composition',
name: 'render 组合式 API',
// #ifdef APP-ANDROID
enable: false,
// #endif
url: 'render-composition'
},
]
},
{
......@@ -1019,9 +1019,9 @@ export default {
},
{
id: 'cloneVNode-composition',
name: 'cloneVNode 组合式 API',
// #ifdef APP-IOS
enable: false,
name: 'cloneVNode 组合式 API',
// #ifdef APP-IOS
enable: false,
// #endif
url: 'cloneVNode-composition'
},
......@@ -1054,9 +1054,9 @@ export default {
},
{
id: 'resolveComponent-composition',
name: 'resolveComponent 组合式 API',
// #ifdef APP-IOS
enable: false,
name: 'resolveComponent 组合式 API',
// #ifdef APP-IOS
enable: false,
// #endif
url: 'resolveComponent-composition'
},
......@@ -1073,9 +1073,9 @@ export default {
},
{
id: 'withDirectives-composition',
name: 'withDirectives 组合式 API',
// #ifdef APP-IOS
enable: false,
name: 'withDirectives 组合式 API',
// #ifdef APP-IOS
enable: false,
// #endif
url: 'withDirectives-composition'
},
......@@ -1092,9 +1092,9 @@ export default {
},
{
id: 'withModifiers-composition',
name: 'withModifiers 组合式 API',
// #ifdef APP-IOS
enable: false,
name: 'withModifiers 组合式 API',
// #ifdef APP-IOS
enable: false,
// #endif
url: 'withModifiers-composition'
},
......
<script setup lang="uts">
import CompForHFunction from '@/components/CompForHFunction.uvue'
defineOptions({
data() {
return {
msg: 'default msg'
}
},
render(): VNode {
const instance = getCurrentInstance()!.proxy!
return h('view', { class: 'page' }, [
h(CompForHFunction, {}, (): VNode[] => [h('text', { class: 'comp-slot' }, 'component slot')]),
h('text', { class: 'uni-common-mt msg', style: { color: 'blue' } }, instance.$data['msg']),
h(
'button',
{
class: 'uni-common-mt btn',
type: 'primary',
onClick: () => {
instance.$data['msg'] = 'new msg'
}
},
'click'
)
])
}
})
const msg = ref('default msg')
const render = ():VNode => h('view', { class: 'page' }, [
h(CompForHFunction, {}, (): VNode[] => [h('text', { class: 'comp-slot' }, 'component slot')]),
h('text', { class: 'uni-common-mt msg', style: { color: 'blue' } }, msg.value),
h(
'button',
{
class: 'uni-common-mt btn',
type: 'primary',
onClick: () => {
msg.value = 'new msg'
}
},
'click'
)
])
</script>
<template><render /></template>
<style>
.btn {
color: red;
}
</style>
\ No newline at end of file
</style>
......@@ -4,7 +4,7 @@ const COMPOSITION_PAGE_PATH = '/pages/render-function/render/render-composition'
describe('render-function render', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isWeb = platformInfo.startsWith('web')
const isIos = platformInfo.startsWith('ios')
const isAndroid = platformInfo.startsWith('android')
if (isWeb) {
it("web platform test cannot get render dom", async () => {
expect(1).toBe(1);
......@@ -38,10 +38,10 @@ describe('render-function render', () => {
})
it('render composition API', async () => {
if (!isIos) {
if (!isAndroid) {
await test(COMPOSITION_PAGE_PATH)
} else {
// TODO: ios 端 defineOptions + render 页面空白
// TODO: android 端 报错 java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
expect(1).toBe(1);
}
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册