vue3 响应值与style绑定
2024-02-21 本文已影响0人
0说
<template>
<div class="num">{{ num }}</div>
</template>
<script lang="ts" setup>
import { inject, ref } from 'vue'
const num = inject<number>('num')
const color = ref('#f60')
</script>
<style scoped>
.num {
color: v-bind(color) // 响应到上面setup的值
}
</style>