fix: 枚举失效问题 & 分离全局声明和模块化内容
This commit is contained in:
parent
28a7f26bd3
commit
f2ae977e9a
@ -31,6 +31,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { TestEnum } from '@/typings'
|
||||
import PLATFORM from '@/utils/platform'
|
||||
|
||||
defineOptions({
|
||||
@ -46,6 +47,7 @@ const description = ref(
|
||||
// 测试 uni API 自动引入
|
||||
onLoad(() => {
|
||||
console.log(author)
|
||||
console.log(TestEnum.A)
|
||||
})
|
||||
</script>
|
||||
|
||||
|
28
src/typings.d.ts
vendored
Normal file
28
src/typings.d.ts
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
// 全局要用的类型放到这里
|
||||
|
||||
declare global {
|
||||
type IResData<T> = {
|
||||
code: number
|
||||
msg: string
|
||||
data: T
|
||||
}
|
||||
|
||||
// uni.uploadFile文件上传参数
|
||||
type IUniUploadFileOptions = {
|
||||
file?: File
|
||||
files?: UniApp.UploadFileOptionFiles[]
|
||||
filePath?: string
|
||||
name?: string
|
||||
formData?: any
|
||||
}
|
||||
|
||||
type IUserInfo = {
|
||||
nickname?: string
|
||||
avatar?: string
|
||||
/** 微信的 openid,非微信没有这个字段 */
|
||||
openid?: string
|
||||
token?: string
|
||||
}
|
||||
}
|
||||
|
||||
export {} // 防止模块污染
|
@ -1,29 +1,6 @@
|
||||
// 全局要用的类型放到这里
|
||||
// 枚举定义
|
||||
|
||||
type IResData<T> = {
|
||||
code: number
|
||||
msg: string
|
||||
data: T
|
||||
}
|
||||
|
||||
// uni.uploadFile文件上传参数
|
||||
type IUniUploadFileOptions = {
|
||||
file?: File
|
||||
files?: UniApp.UploadFileOptionFiles[]
|
||||
filePath?: string
|
||||
name?: string
|
||||
formData?: any
|
||||
}
|
||||
|
||||
type IUserInfo = {
|
||||
nickname?: string
|
||||
avatar?: string
|
||||
/** 微信的 openid,非微信没有这个字段 */
|
||||
openid?: string
|
||||
token?: string
|
||||
}
|
||||
|
||||
enum TestEnum {
|
||||
A = 'a',
|
||||
B = 'b',
|
||||
export enum TestEnum {
|
||||
A = '1',
|
||||
B = '2',
|
||||
}
|
||||
|
@ -20,7 +20,8 @@
|
||||
"@uni-helper/uni-types",
|
||||
"@types/wechat-miniprogram",
|
||||
"wot-design-uni/global.d.ts",
|
||||
"z-paging/types"
|
||||
"z-paging/types",
|
||||
"./src/typings.d.ts"
|
||||
]
|
||||
},
|
||||
"vueCompilerOptions": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user