Performance: Shorthand syntax (: and @)
This affects how Vue templates compile and how event listeners and bindings are processed, impacting rendering speed and bundle size slightly.
<MyButton :title="buttonTitle" @click="handleClick" />
<MyButton v-bind:title="buttonTitle" v-on:click="handleClick" />
| Pattern | Template Size | Parsing Speed | Bundle Size Impact | Verdict |
|---|---|---|---|---|
| Verbose syntax (v-bind, v-on) | Larger | Slower | Slightly larger | [X] Bad |
| Shorthand syntax (:, @) | Smaller | Faster | Slightly smaller | [OK] Good |
: represent in Vue templates?v-bind: is used to bind data to HTML attributes.v-bind:v-bind: is :, which simplifies template syntax.v-bind: to bind data to attributes. -> Option A: = v-bind: [OK]v-on: to listen to events, and its shorthand is @.@click="handleClick".@ = v-on: [OK]<template> <input :value="username" @input="updateName" /> </template>
username is 'Alice' and updateName updates username on input.: and @ usage: binds the value attribute to username, so input shows 'Alice'. @input listens for input events to call updateName.username as user types.<button :click="submitForm">Submit</button>
v-on: or shorthand @, not v-bind: or :.:click, which is wrong; it should be @click.save on a component. Which is the correct Vue shorthand syntax?: shorthand for v-bind: to bind class dynamically.@ shorthand for v-on: to listen for save event.<MyComponent :class="dynamicClass" @save="handleSave" /> correctly binds class and listens to save event with proper shorthand.Pass the test and this pattern moves unknown