Files
aiot-uniapp/src/pages/about/components/VBindCss.vue
feige996 ccebecaed8 refactor(about): 将v-bind css变量功能抽离为独立组件
将原本在about.vue中的v-bind css变量相关代码抽离到单独的VBindCss组件中,提高代码可维护性
2025-08-28 15:02:57 +08:00

28 lines
598 B
Vue

<script lang="ts" setup>
const testBindCssVariable = ref('red')
function changeTestBindCssVariable() {
if (testBindCssVariable.value === 'red') {
testBindCssVariable.value = 'green'
}
else {
testBindCssVariable.value = 'red'
}
}
</script>
<template>
<button class="mt-4 w-60 text-center" @click="changeTestBindCssVariable">
toggle v-bind css变量
</button>
<view class="test-css my-2 text-center">
测试v-bind css变量的具体文案
</view>
</template>
<style lang="scss" scoped>
.test-css {
color: v-bind(testBindCssVariable);
font-size: 24px;
}
</style>