vue动态改变background-img
<template><div :style = "{background:'url('+imgCdnUrl+'banner.jpg) no-repeat top center 100%/100%''}"></div></template><script>export default{data(){return{...
·
<template>
<div :style = "{background:'url('+imgCdnUrl+'banner.jpg) no-repeat top center 100%/100%''}">
</div>
</template>
<script>
export default{
data(){
return{
imgCdnUrl:window.pcImgCdnUrl
}
}
}
</script>
:style = "{background:‘url(’+imgCdnUrl+‘banner.jpg) no-repeat top center 100%/100%’’}"
动态改变背景图片 100%/100% 是 background-size 属性
window.pcImgCdnUrl
这个是配置文件中定义的公共变量
更多推荐
已为社区贡献7条内容
所有评论(0)