Attribute Bindings
Part of the Fundamentals section of Coddy's Vue journey. Lesson 4 of 55.
Use v-bind to set an attribute from a JavaScript expression. The colon is its shorthand. This link gets /catalog as its destination, while its text is ordinary HTML.
const url = '/catalog';
// Template: <a :href="url">Browse books</a>Without the colon, href="url" is the literal string url. With it, Vue reads the variable. A boolean binding such as :disabled="false" leaves a button enabled; the string "false" is not a false boolean.
Challenge
EasyThe supplied data describes a workshop link. Bind a#result to destination as its href, label as its title, and display label as its text. The values are /workshops and Explore workshops.
Try it yourself
<!doctype html><html><head><meta charset="UTF-8"><title>Vue practice</title></head><body><div id="app"></div><script type="module" src="./main.js"></script></body></html>This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
2Reactive State
Reactive RefsUpdating Refs in ScriptEvent Handler ArgumentsReactive ObjectsRecap: Reactive State5Conditions and Lists
Conditional BranchesShow without UnmountingRendering ListsStable List IdentityRecap: Conditions8Component Communication
Emitting EventsEvent PayloadsLifting Shared StateDefault and Named SlotsRecap: Shared Panel11Project: Community Board
Board StructureAdding Community Tasks