<template> <div> <h3>style的使用</h3> <div style="300px; height:200px;margin:10px auto;" :style="{backgroundColor:bgColor,fontSize:fSize}">样式可以是字符串</div> </div> </template> <script> export default{ name:"ClassAndStyle2", data(){ return { bgColor:"yellow", fSize:"10px", } } } </script> <style scoped> </style>