<template>
<div :style="styleText" class="div1"></div>
</template>
<script>
export default {

data () {
return {
styleText: {
'--text-color': 'red'
}
}
},
mounted () {
// 获取 css 属性值
const color = getComputedStyle(document.documentElement).getPropertyValue('--text-color')

}
}

</script>
<style>
.div1 {
color: var(--text-color);
}
</style>

  

相关文章:

  • 2021-12-20
  • 2022-12-23
  • 2019-11-23
  • 2021-09-04
  • 2021-04-15
  • 2021-07-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-02
  • 2022-12-23
  • 2020-05-27
  • 2022-12-23
相关资源
相似解决方案