feat: ts学习之never使用场景
parent
7aa97eaf23
commit
8876f4003d
@ -0,0 +1,20 @@
|
||||
<template>
|
||||
<div class="p-5 space-y-5 !bg-gray-100">
|
||||
<el-card header="never类型使用场景">
|
||||
<h1 @click="limitParamsType('test')">传入的类型不能为number</h1>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
|
||||
const limitParamsType = <T,>(parmas: T extends number ? never : T) => {
|
||||
console.log(parmas);
|
||||
};
|
||||
|
||||
limitParamsType('acc');
|
||||
// limitParamsType(123)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
Loading…
Reference in New Issue