<div style="color: #f40;">hi,there</div> <div style="fontSize: 20px">hi,there</div> <div style="background-color: #f40;">hi,there</div> <div style="background-image: url(./todo/todo0.jpg)">hi,there</div> <div style="backgroundColor: #f40;">hi,there</div>
<div :style="{ 'color': txtColor }">hi,there</div> <div :style="{ 'background-color': color }">content</div> <div :style="{ 'backgroundColor': color }">content</div>
<div :style="{ 'fontSize': small + 'px' }">hi,there</div> <div :style="{ 'lineHeight': h + 'px' }">content</div>
<div :style="{ 'backgroundImage': 'url(' + imgUrl + ')' }">content</div> <div :style="{ 'background-image': 'url(' + imgUrl + ')' } ">content</div>
<div :style="`background-image:url(${imgUrl})`">content</div>
模板字符串不支持小驼峰写法
<div :style="`backgroundImage:url(${imgUrl})`">content</div>
<div :style="{ 'backgroundColor': color, 'lineHeight': h + 'px' }">content</div>
<div style="background-image: url('/imgs/lg.jpg');">hi,there</div>
import url from '../assets/imgs/0.jpg'
<div class="box" :style="{ backgroundImage: 'url(' + src + ')' }">hi,there</div> <div class="box" :style="{ backgroundImage: 'url(' + url + ')' }">hi,there</div>