uniapp动态设置style
文章描述:
uniapp动态设置style样式属性
对象方式
:style="{marginTop:top+'px',marginBottom:'30px',marginLeft:'auto',marginRight:'auto'}"
:style="{backgroundImage:`url(${img})`}"
对象数组方式
:style="[{background: bgColor},{padding: padding+'px'}]"
script
export default{
	data(){
		return{
			top:30,
			img:'../../static/images/1.png',
			bgColor:'#4bcdff',
			padding:30,
		}
	}
}
style
.box{
	width: 300upx;
	height: 300upx;
	background: #4bcdff;
}
发布时间:2022/12/21 
                
            
发表评论