Menu
CoddyTech

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 icon

Challenge

Easy

The 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>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals