vue 3.2 新增 https://blog.vuejs.org/posts/vue-3.2.html

    1. <template>
    2. <div class="text">123123</div>
    3. </template>
    4. <script setup>
    5. const color = "red"
    6. const font = {
    7. size:"2em"
    8. }
    9. </script>
    10. <style scoped>
    11. /*一般CSS用法,定义变量*/
    12. root {
    13. --varColor: yellowgreen;
    14. }
    15. /*Vue3 语法糖,可以直接用v-bind绑定上面script标签里面的变量*/
    16. .text{
    17. color: v-bind(color);
    18. font-size: v-bind("font.size");
    19. }
    20. </style>