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、效果如下: