Vue3 & TypeScript ---- 伪元素动态样式
作者:
牛会骑自行车 | 来源:发表于
2023-09-25 16:17 被阅读0次
效果图
<script lang="ts" setup>
const beforeWidth = ref('50px');
</script>
<template>
<div class="fake-view" :style="{'--width': beforeWidth}"></div>
</template>
<style lang="scss" scoped>
.fake-view {
height: 40px;
background: lightgrey;
position: relative;
}
.fake-view::before {
content: '';
display: block;
width: var(--width);
height: 100%;
background: red;
position: absolute;
top: 0;
left: 0;
}
</style>
本文标题:Vue3 & TypeScript ---- 伪元素动态样式
本文链接:https://www.haomeiwen.com/subject/gfkcbdtx.html
网友评论