<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>
网友评论