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

refactor: 优化代码

上级 5f70c618
...@@ -16,28 +16,26 @@ ...@@ -16,28 +16,26 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
defineProps({ export type FooPropsObj = {
title: { name : string
type: String,
default: ''
},
num: {
type: Number,
default: 0
},
checked: {
type: Boolean,
default: false
},
obj: {
// #ifdef APP-ANDROID
// TODO: 确认类型是否合理
type: FooPropsObj1ReactiveObject,
// #endif
// #ifdef APP-IOS || WEB
type: Object,
// #endif
required: true
} }
})
</script> defineProps({
title: {
type: String,
default: ''
},
num: {
type: Number,
default: 0
},
checked: {
type: Boolean,
default: false
},
obj: {
type: FooPropsObj,
required: true
}
})
</script>
\ No newline at end of file
...@@ -15,7 +15,11 @@ ...@@ -15,7 +15,11 @@
</view> </view>
</template> </template>
<script lang="uts"> <script lang="uts">
export type FooPropsObj = {
name : string
}
export default { export default {
props: { props: {
title: { title: {
...@@ -31,12 +35,7 @@ ...@@ -31,12 +35,7 @@
default: false default: false
}, },
obj: { obj: {
// #ifdef APP-ANDROID type: FooPropsObj,
type: FooPropsObjReactiveObject,
// #endif
// #ifdef APP-IOS || WEB
type: Object,
// #endif
required: true required: true
} }
} }
......
...@@ -42,10 +42,8 @@ ...@@ -42,10 +42,8 @@
<script setup lang="uts"> <script setup lang="uts">
import Foo from './Foo-composition.uvue' import Foo from './Foo-composition.uvue'
import {type FooPropsObj} from './Foo-composition.uvue'
type FooPropsObj = {
name : string
}
type FooProps = { type FooProps = {
title : string title : string
num : number num : number
...@@ -69,7 +67,7 @@ const dataInfo = reactive({ ...@@ -69,7 +67,7 @@ const dataInfo = reactive({
num: 1, num: 1,
obj: { obj: {
name: 'foo obj name', name: 'foo obj name',
} } as FooPropsObj
}, },
vBindClassBackgroundColor: 'red', vBindClassBackgroundColor: 'red',
vBindClassRpxHeight: '300rpx' vBindClassRpxHeight: '300rpx'
......
...@@ -32,10 +32,8 @@ ...@@ -32,10 +32,8 @@
<script lang="uts"> <script lang="uts">
import Foo from './Foo-options.uvue' import Foo from './Foo-options.uvue'
import {type FooPropsObj} from './Foo-options.uvue'
type FooPropsObj = {
name: string
}
type FooProps = { type FooProps = {
title: string title: string
num: number num: number
...@@ -63,7 +61,7 @@ export default { ...@@ -63,7 +61,7 @@ export default {
num: 1, num: 1,
obj: { obj: {
name: 'foo obj name' name: 'foo obj name'
} } as FooPropsObj
}, },
vBindClassBackgroundColor: 'red', vBindClassBackgroundColor: 'red',
vBindClassRpxHeight: '300rpx' vBindClassRpxHeight: '300rpx'
......
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
import { state } from '@/store/index.uts' import { state } from '@/store/index.uts'
onReady(() => { onReady(() => {
throw Error('error in error composition page onReady') throw new Error('error in error composition page onReady')
}) })
const triggerError = () => { const triggerError = () => {
throw Error('trigger error in throw error composition page') throw new Error('trigger error in throw error composition page')
} }
// 自动化测试 // 自动化测试
......
...@@ -9,11 +9,11 @@ import { state } from '@/store/index.uts' ...@@ -9,11 +9,11 @@ import { state } from '@/store/index.uts'
export default { export default {
onReady(){ onReady(){
throw Error('error in error options page onReady') throw new Error('error in error options page onReady')
}, },
methods: { methods: {
triggerError(){ triggerError(){
throw Error('trigger error in throw error options page') throw new Error('trigger error in throw error options page')
}, },
// 自动化测试 // 自动化测试
getLifeCycleNum() : number { getLifeCycleNum() : number {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册