流浪のwolf

卷帝

导航

vue 的常用指令以及作用 ·

1、 v-model 多用于表单元素实现双向数据绑定(同 angular 中的 ng-model)

2、 v-for 格式: v-for="字段名 in(of) 数组 json" 循环数组或 json(同 angular 中的ng-repeat),需要注意从 Vue2 开始取消了$index

3、 v-show 显示内容 (同 angular 中的 ng-show)

4、 v-hide 隐藏内容(同 angular 中的 ng-hide)

5、 v-if 显示与隐藏 (dom 元素的删除添加 同 angular 中的 ng-if 默认值为false)

6、 v-else-if 必须和 v-if 连用

7、 v-else 必须和 v-if 连用 不能单独使用 否则报错 模板编译错误

8、 v-bind 动态绑定 作用: 及时对页面的数据进行更改

9、 v-on:click 给标签绑定函数,可以缩写为@,例如绑定一个点击函数 函数必须写在methods 里面

10、v-text 解析文本

11、v-html 解析 html 标签

12、v-bind:class 三种绑定方法 1、对象型 '{red:isred}' 2、三元型 'isred?"red":"blue"' 3、数组型'[{red:"isred"},{blue:"isblue"}]'

13、v-once 进入页面时 只渲染一次 不在进行渲染

14、v-cloak 防止闪烁

15、v-pre 把标签内部的元素原位输出

posted on 2022-10-16 19:04  流浪のwolf  阅读(46)  评论(0编辑  收藏  举报