Vue的基础语法(常用)
其他
2019-03-28 17:11:20
阅读次数: 0
模板语法:
- Mustache语法{{msg}}
- Html赋值 v-html="‘’
- 绑定属性:v-bind:id=""
- 使用表达式:{{ok? ‘YES’:‘NO’}}
- 文本赋值:v-text=""
- 指令:v-if=""
- 过滤器:{{message|capitalize}} 和v-bind:id=“rawId|formatId”
Class和Style绑定:
- 对象语法:v-bind:class ="{active:isActive}"
- 数组语法:
data{
activeClass:‘active’,
errorClass:‘text-danger’
}
- style绑定-对象语法:v-bind:style="{color:activeColor,fontSize:fontsize+‘px’}"
条件渲染:
- v-if
- v-else
- v-else-if
- v-show
- v-cloak
Vue事件处理:
- v-on:click=‘greet’ 或者@click="greet‘’
- v-on:click.stop,v-on:click.stop.prevent,v-on:click.self,v-on:click.once
- v-on:keyup.enter
.tab
.delete
esc
.space
.up
.down
.left
.right
Vue组件:
- 全局组件和局部组件
- 父子组件通讯—数据传递 parent-(pass(props))>child child-(emit(event))>parent
- slot(插槽)
转载自blog.csdn.net/u012967454/article/details/88775340