v-top
简介
被v-top
绑定的元素会始终保持在最高层,即 zIndex 全局最高。
使用方法
给需要置顶的元素添加v-top
指令即可。
查看代码
vue
<script setup lang="ts">
import { vTop, vDrag } from '@cp-vuedir/core'
</script>
<template>
<a-card
:style="{
width: '100%',
height: '30vh'
}"
>
<a-button size="large" type="primary" v-drag="{}" v-top> 我就是那 z-index 之王! </a-button>
<a-button
size="large"
type="warning"
v-drag
style="
{
z-index: 9999;
}
"
>
我的 z-index 是9999
</a-button>
</a-card>
</template>
注意事项
警告!
- 全局应该只存在一个
v-top
指令,否则会导致置顶元素错乱。