feat(demo): enum 使用范例

This commit is contained in:
菲鸽 2024-03-01 14:27:45 +08:00
parent 5e1dd51802
commit eb81b89a37
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,21 @@
<route lang="json5" type="page">
{
style: { navigationBarTitleText: 'enum' },
}
</route>
<template>
<view class="">enum</view>
</template>
<script lang="ts" setup>
import { TestEnum } from '@/typings.d'
type T = TestEnum.A
const a = 'a' as T
console.log(a)
</script>
<style lang="scss" scoped>
//
</style>

6
src/typings.d.ts vendored
View File

@ -1,3 +1,4 @@
/* eslint-disable no-unused-vars */
// 全局要用的类型放到这里
export type IResData<T> = {
@ -13,3 +14,8 @@ export type IUserInfo = {
openid?: string
token?: string
}
export enum TestEnum {
A = 'a',
B = 'b',
}