Vue的基础语法(常用)

模板语法:

  1. Mustache语法{{msg}}
  2. Html赋值 v-html="‘’
  3. 绑定属性:v-bind:id=""
  4. 使用表达式:{{ok? ‘YES’:‘NO’}}
  5. 文本赋值:v-text=""
  6. 指令:v-if=""
  7. 过滤器:{{message|capitalize}} 和v-bind:id=“rawId|formatId”

Class和Style绑定:

  1. 对象语法:v-bind:class ="{active:isActive}"
  2. 数组语法:

    data{
    activeClass:‘active’,
    errorClass:‘text-danger’
    }
  3. style绑定-对象语法:v-bind:style="{color:activeColor,fontSize:fontsize+‘px’}"

条件渲染:

  1. v-if
  2. v-else
  3. v-else-if
  4. v-show
  5. v-cloak

Vue事件处理:

  1. v-on:click=‘greet’ 或者@click="greet‘’
  2. v-on:click.stop,v-on:click.stop.prevent,v-on:click.self,v-on:click.once
  3. v-on:keyup.enter
    .tab
    .delete
    esc
    .space
    .up
    .down
    .left
    .right

Vue组件:

  1. 全局组件和局部组件
  2. 父子组件通讯—数据传递 parent-(pass(props))>child child-(emit(event))>parent
  3. slot(插槽)

猜你喜欢

转载自blog.csdn.net/u012967454/article/details/88775340