25.06.2018 Views

Full-Stack Vue.js 2 and Laravel 5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Style binding<br />

To set a background image, we must provide the URL as a property in a CSS<br />

rule like this: .header .header-img { background-image: url(...); }<br />

Obviously, our header image should be specific to each individual listing, so we<br />

don't want to hard code this CSS rule. Instead, we can have <strong>Vue</strong> bind the URL<br />

from data to our template.<br />

<strong>Vue</strong> can't access our CSS style sheet, but it can bind to an inline style attribute:<br />

<br />

You may think using a text interpolation is the solution here, for example: <br />

But this is not valid <strong>Vue</strong>.<strong>js</strong> syntax. This is, instead, a job for another <strong>Vue</strong>.<strong>js</strong><br />

feature called a directive. Let's explore directives first <strong>and</strong> then come back to<br />

solving this problem.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!