1 <template> 2 <div :style="styleText" class="div1"></div> 3 </template> 4 <script> 5 data () { 6 return { 7 styleText: { 8 ‘--text-color‘: ‘red‘ 9 } 10 } 11 } 12 </script> 13 <style> 14 .div1 { 15 color: var(--text-color); 16 } 17 </style>
原文:https://www.cnblogs.com/W-it-H-ou-T/p/14452832.html