1、代码如下:
<template><div :style="{color:activeColor,fontSize:fontsize+'px'}">Style绑定1</div><div :style="styleObject">Style绑定2</div><div :style="[styleObject]">Style绑定3</div> </template><script> export default {data() {return {activeColor: "green",fontsize: '30',styleObject: {color: 'red',fontSize: '20px',}}} } </script><style> </style>
2、效果如下: