Search
 
SCRIPT & CODE EXAMPLE
 

HTML

vue bind

<!-- bind an attribute -->
<img v-bind:src="imageSrc" />

<!-- dynamic attribute name -->
<button v-bind:[key]="value"></button>

<!-- shorthand -->
<img :src="imageSrc" />

<!-- shorthand dynamic attribute name -->
<button :[key]="value"></button>

<!-- with inline string concatenation -->
<img :src="'/path/to/images/' + fileName" />

<!-- class binding -->
<div :class="{ red: isRed }"></div>
<div :class="[classA, classB]"></div>
<div :class="[classA, { classB: isB, classC: isC }]"></div>

<!-- style binding -->
<div :style="{ fontSize: size + 'px' }"></div>
<div :style="[styleObjectA, styleObjectB]"></div>

<!-- binding an object of attributes -->
<div v-bind="{ id: someProp, 'other-attr': otherProp }"></div>

<!-- prop binding. "prop" must be declared in the child component. -->
<MyComponent :prop="someThing" />

<!-- pass down parent props in common with a child component -->
<MyComponent v-bind="$props" />

<!-- XLink -->
<svg><a :xlink:special="foo"></a></svg>
Comment

v-bind

<div v-bind:class="{ active: isActive }"></div>
The above syntax means the presence of the active class will be determined by the truthiness of the data property isActive.
Comment

PREVIOUS NEXT
Code Example
Html :: on change event html not working 
Html :: bootstrap upload image plugin for html 
Html :: nuxt i18 
Html :: html popup form 
Html :: style attribute in html 
Html :: html form to google sheets 
Html :: action_page.php 
Html :: ean 13 barcode in javascript tutorial 
Html :: custom radio css 
Html :: bootstrap 5 tooltip html 
Html :: <!DOCTYPE html eslint error 
Html :: href open in new tab 
Html :: html li tag 
Html :: create link inertia-svelte 
Html :: indice html 
Html :: slider with steps 
Html :: ml-auto not working 
Html :: video values in html 
Html :: copy to cllipboard the html element 
Html :: bootstrap input tagsinput 
Html :: html to pdf react 
Html :: html form tag 
Html :: angular call function from html 
Html :: headings in html 
Html :: html to jpg 
Html :: inline code html 
Html :: Using SVG as an <img 
Html :: input name html 
Html :: Przezroczysty div 
Html :: tina4 form token example 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =