Skip to content

Commit eb81b89

Browse files
committed
feat(demo): enum 使用范例
1 parent 5e1dd51 commit eb81b89

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/pages/demo/base/enum.vue

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<route lang="json5" type="page">
2+
{
3+
style: { navigationBarTitleText: 'enum' },
4+
}
5+
</route>
6+
7+
<template>
8+
<view class="">enum</view>
9+
</template>
10+
11+
<script lang="ts" setup>
12+
import { TestEnum } from '@/typings.d'
13+
14+
type T = TestEnum.A
15+
const a = 'a' as T
16+
console.log(a)
17+
</script>
18+
19+
<style lang="scss" scoped>
20+
//
21+
</style>

src/typings.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-unused-vars */
12
// 全局要用的类型放到这里
23

34
export type IResData<T> = {
@@ -13,3 +14,8 @@ export type IUserInfo = {
1314
openid?: string
1415
token?: string
1516
}
17+
18+
export enum TestEnum {
19+
A = 'a',
20+
B = 'b',
21+
}

0 commit comments

Comments
 (0)