Notes of Vue
update at 15-8-2021, review what I know about Vue
Commands of Vue
There are total 12 commands in Vue(More now, but I only know 12)
v-bind
Passing a data to html, we can use v-bind
, it can pass the object and array to html:<div v-bind:class="[activeClass, errorClass]"></div>
v-once
v-once use when the data will never change, This can be used to optimise update performance
v-model
v-text
v-html
v-on
v-if
v-else
v-show
v-for
v-pre
v-clock
Vue const create
1 | const app = Vue.createApp({ |
or
1 | var app = new Vue({ |
v-on
v-on
can replace by @
, for example v-on:click="functionName"
=== @click="functionName"
Used in <div>
, for example:
1 | <div id="app"> |
v-bind
v-bind is used when attribute in vue instance is needed,
When we try to:<a href={{website}}>some website<a>
It won’t work
we need to use v-bind
:<a v-bind:href={{website}}>some website<a>
v-bind
can be replaced by :
<a :href={{website}}>some website<a>
v-if, v-else
Just another if-else statement, but there are a notice able use case:
1 | <button @click="function"> |
v-for
To show an array of data, we need to use v-for
1 | books:[ |
1 | <ul> |