代码如下
<div :style="{background: 'url(' + item.home_img + ') center center', backgroundSize: '100%'}">
:style声明数据通过变量的形式添加到html文档中
注意
- 属性中存在'-'需要修改,如background-size需要修改成backgroundSize或者‘background-size’
- 属性的值如果不是变量,需要加引号,如'100%'
代码如下
<div :style="{background: 'url(' + item.home_img + ') center center', backgroundSize: '100%'}">
:style声明数据通过变量的形式添加到html文档中
注意