refactor(about): 将v-bind css变量功能抽离为独立组件
将原本在about.vue中的v-bind css变量相关代码抽离到单独的VBindCss组件中,提高代码可维护性
This commit is contained in:
27
src/pages/about/components/VBindCss.vue
Normal file
27
src/pages/about/components/VBindCss.vue
Normal file
@@ -0,0 +1,27 @@
|
||||
<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>
|
||||
Reference in New Issue
Block a user