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

refactor: 示例优化,移除条件编译

上级 7d773734
......@@ -4,12 +4,7 @@
const originalVNode = h('view', { class: 'original' }, [
h('text', {}, 'Hello World'),
])
// #ifdef APP-ANDROID
const clonedVNode = cloneVNode(originalVNode, new Map<string, any | null>([['class', 'cloned']]))
// #endif
// #ifdef WEB || APP-IOS
const clonedVNode = cloneVNode(originalVNode, { class: 'cloned'})
// #endif
const clonedVNode = cloneVNode(originalVNode, { class: 'cloned' })
return h('view', { class: 'flex flex-col' }, [originalVNode, clonedVNode])
}
......
......@@ -4,12 +4,7 @@
const originalVNode = h('view', { class: 'original' }, [
h('text', {}, 'Hello World'),
])
// #ifdef APP-ANDROID
const clonedVNode = cloneVNode(originalVNode, new Map<string, any | null>([['class', 'cloned']]))
// #endif
// #ifdef WEB || APP-IOS
const clonedVNode = cloneVNode(originalVNode, { class: 'cloned'})
// #endif
const clonedVNode = cloneVNode(originalVNode, { class: 'cloned' })
return h('view', { class: 'flex flex-col' }, [originalVNode, clonedVNode])
}
......
......@@ -14,12 +14,7 @@
<script setup lang="uts">
const isVNodeVNode = ref(false)
const isVNodeString = ref(false)
// #ifdef APP-ANDROID
const vnode = h('text', new Map<string, any | null>(), 'Hello World')
// #endif
// #ifndef APP-ANDROID
const vnode = h('text', {}, 'Hello World')
// #endif
isVNodeVNode.value = isVNode(vnode)
isVNodeString.value = isVNode('abc')
</script>
</script>
\ No newline at end of file
......@@ -12,23 +12,17 @@
</template>
<script lang="uts">
export default {
data(){
return {
isVNodeVNode: false,
isVNodeString: false
export default {
data() {
return {
isVNodeVNode: false,
isVNodeString: false
}
},
onLoad() {
const vnode = h('text', {}, 'Hello World')
this.isVNodeVNode = isVNode(vnode)
this.isVNodeString = isVNode('abc')
}
},
onLoad(){
// TODO: 确认 android 端与其他端差异
// #ifdef APP-ANDROID
const vnode = h('text', new Map<string, any | null>(), 'Hello World')
// #endif
// #ifndef APP-ANDROID
const vnode = h('text', {}, 'Hello World')
// #endif
this.isVNodeVNode = isVNode(vnode)
this.isVNodeString = isVNode('abc')
}
}
</script>
</script>
\ No newline at end of file
......@@ -15,13 +15,6 @@
<script setup lang="uts">
type PropFn = () => string
// TODO: 确认 android 与 web & ios 差异
// #ifdef APP-ANDROID
const propA = new Map<string, any | null>([['class', 'foo'], ['onClick', () : string => 'propA click res']])
const propB = new Map<string, any | null>([['class', { bar: true }], ['onClick', () : string => 'propB click res']])
const mergedProps = ref(new Map<string, any | null>())
// #endif
// #ifndef APP-ANDROID
const propA = {
class: 'foo',
onClick: () : string => 'propA click res'
......@@ -31,11 +24,10 @@
onClick: () : string => 'propB click res'
}
const mergedProps = ref({})
// #endif
const propFnResList = ref<string[]>([])
mergedProps.value = mergeProps(propA, propB)
const triggerMergedClick = () => {
(mergedProps.value['onClick'] as PropFn[]).forEach(fn => { propFnResList.value.push(fn()) })
}
......
......@@ -17,13 +17,6 @@
export default {
data() {
return {
// TODO: 确认 android 与 web & ios 差异
// #ifdef APP-ANDROID
propA: new Map<string, any | null>([['class', 'foo'], ['onClick', () : string => 'propA click res']]),
propB: new Map<string, any | null>([['class', { bar: true }], ['onClick', () : string => 'propB click res']]),
mergedProps: new Map<string, any | null>(),
// #endif
// #ifndef APP-ANDROID
propA: {
class: 'foo',
onClick: () : string => 'propA click res'
......@@ -33,7 +26,6 @@
onClick: () : string => 'propB click res'
},
mergedProps: {},
// #endif
propFnResList: [] as string[],
}
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册