我是靠谱客的博主 勤奋面包,这篇文章主要介绍Vue标签属性, v-bind 条件渲染, v-if v-else v-show,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<template> <div id="app"> <ul> <li v-for="(item,index) in list" :key="index" > {{item}} </li> </ul> <!-- V-bind绑定标签属性, 简写: 使用v-bind就是变量, 不使用就是常亮 :class="[classA,classB]" data:{ classA:'hello', classB:'world' } --> <componentA :dataA="dataA" ></componentA> <a :href="link" :title='HELLO' class="2" :class="classa" :style="linkCss">to baidu</a> <button v-on:click="addItem">addItem</button> <a v-if="isPartA">A</a> <a v-else>no a</a> <a v-show="!isPartA">B</a> <button v-on:click="toggle">切换</button> </div> </template> <script> //如果要使用vue全局. import Vue from 'vue' export default { data() { return { isPartA:true, link:'http://www.baidu.com', HELLO: "<span>world</span>", num: 1, linkCss:{'color':'red'}, classa:'AAAA', dataA:2, status: true, list: [ { name: "apple", price: 34 }, { name: "ban", price: 34 } ], objList:{ name:'apple', price:34, color:'red', weight:14 } } }, //绑定方法 methods:{ addItem (){ console.log(this.list); //有的方法不能实现双向绑定怎么办 Vue.set(this.list,1,{ name: "ban1", price: 341 }); /* this.list.push({ name: "ban1", price: 341 }) */ } , toggle(){ this.isPartA=! this.isPartA; } } }; </script> <style> </style>

 

最后

以上就是勤奋面包最近收集整理的关于Vue标签属性, v-bind 条件渲染, v-if v-else v-show的全部内容,更多相关Vue标签属性,内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(63)

评论列表共有 0 条评论

立即
投稿
返回
顶部