Skip to content

Commit fbdc1a3

Browse files
authored
Update class-and-style.md
Adds an example for using CSS Functions.
1 parent ad4caf0 commit fbdc1a3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/guide/essentials/class-and-style.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,20 @@ You can provide an array of multiple (prefixed) values to a style property, for
338338
```
339339

340340
This will only render the last value in the array which the browser supports. In this example, it will render `display: flex` for browsers that support the unprefixed version of flexbox.
341+
342+
### CSS Functions
343+
It is best to practice to use JavaScript objects to return CSS functions like `url()`:
344+
```vue-html
345+
<div :style=:style="{backgroundImage: this.myUrl}"></div>
346+
```
347+
```javascript
348+
computed: {
349+
myUrl() {
350+
return 'url(https://www.foo.com' + this.icon + '.png)'
351+
}
352+
},
353+
```
354+
However, it is also possible to place them in-line using quotes:
355+
```vue-html
356+
<div :style=:style="{ 'backgroundImage': 'url(' + this.icon + '.png)' }"></div>
357+
```

0 commit comments

Comments
 (0)