- Full-Stack Vue.js 2 and Laravel 5
- Anthony Gore
- 105字
- 2021-07-02 19:57:21
Class binding
How we'll approach this is to dynamically bind thecontractedclass. Let's create acontracteddata propertyand set its initial value totrue.
app.js:
data: { ... contracted: true }
Like our style binding, we can bind this class to an object. In the expression, thecontractedpropertyis the name of the class to be bound, thecontractedvalueis a reference to the data property of that same name, which is a Boolean. So if thecontracteddata propertyevaluates totrue, that class will be bound to the element, and if it evaluates to false, it will not.
index.html:
<p v-bind:class="{ contracted: contracted }">{{ about }}</p>
It follows that when the page loads the contracted class is bound:
<p class="contracted">...</p>
推薦閱讀
- Kibana Essentials
- CockroachDB權威指南
- Getting Started with ResearchKit
- Power Up Your PowToon Studio Project
- Interactive Data Visualization with Python
- Vue.js 3.x從入門到精通(視頻教學版)
- Python深度學習
- 數據結構(Java語言描述)
- Java應用開發技術實例教程
- Building Minecraft Server Modifications
- Learning Data Mining with R
- Apache Spark 2.x for Java Developers
- C#開發案例精粹
- Learning Modular Java Programming
- Java程序設計與項目案例教程