Vue.js数据绑定样式backgroundImage不起作用

JavaScript

Tony米亚

2020-03-11

我正在尝试将图像的src绑定到一个元素中,但是它似乎不起作用。我收到“无效的表达式。生成的函数主体:{backgroundImage:{url(image)}”。

文档说使用“ Kebab-case”或“ camel-case”。

<div class="circular" v-bind:style="{ backgroundImage: { url(image) }"></div>

这是一个小提琴:https : //jsfiddle.net/0dw9923f/2/

第533篇《Vue.js数据绑定样式backgroundImage不起作用》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

1个回答
猪猪小卤蛋 2020.03.11
<div :style="{ backgroundImage: `url(${post.image})` }">

there are multiple ways but i found template string easy and simple

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android