25.06.2018 Views

Full-Stack Vue.js 2 and Laravel 5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Class binding<br />

How we'll approach this is to dynamically bind the contracted class. Let's create a<br />

contracted data property <strong>and</strong> set its initial value to true.<br />

app.<strong>js</strong>: data: { ... contracted: true }<br />

Like our style binding, we can bind this class to an object. In the expression, the<br />

contracted property is the name of the class to be bound, the contracted value is a<br />

reference to the data property of that same name, which is a Boolean. So if the<br />

contracted data property evaluates to true, that class will be bound to the element,<br />

<strong>and</strong> if it evaluates to false, it will not.<br />

index.html: {{ about }}<br />

It follows that when the page loads the contracted class is bound: ...

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

Saved successfully!

Ooh no, something went wrong!