Vue实现动态样式

通过占位符${width}

<script setup>
import { ref } from "vue";
let width = ref(100);
</script>

<template>
  <div class="test" :style="`width: ${width}px`">dsd</div>
  </template>

<style scoped lang="scss">
.test {
  background-color: #e64141;
}
</style>

你可能感兴趣的:(vue.js,前端,javascript)