feat(demo): enum 使用范例
This commit is contained in:
parent
5e1dd51802
commit
eb81b89a37
21
src/pages/demo/base/enum.vue
Normal file
21
src/pages/demo/base/enum.vue
Normal 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
6
src/typings.d.ts
vendored
@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable no-unused-vars */
|
||||||
// 全局要用的类型放到这里
|
// 全局要用的类型放到这里
|
||||||
|
|
||||||
export type IResData<T> = {
|
export type IResData<T> = {
|
||||||
@ -13,3 +14,8 @@ export type IUserInfo = {
|
|||||||
openid?: string
|
openid?: string
|
||||||
token?: string
|
token?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum TestEnum {
|
||||||
|
A = 'a',
|
||||||
|
B = 'b',
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user