强制绑定style属性
1、案例1
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>强制绑定style属性</title> </head> <body> <div id="app"> <!--style="color: blue; font-size: 50px;"--> <p :style="{color:'blue',fontSize:myFontSize+'px'}">pppppppppppppppppp</p> <!--color: red; font-size: 35px;--> <p :style="myStyle">pppppppppppppppppp</p> </div> <script src="../js/vue.js" type="text/javascript"></script> <script> const vm = new Vue({ el: "#app", data: { myFontSize: 50, myStyle: { color: "red", fontSize: "35px" } } }); </script> </body> </html>
相识是缘