条件渲染v-if、v-show

<template>
<div>
<a v-if="isPartA">partA</a>
<a v-show="!isPartA">partB</a>
<button v-on:click="toggle">toggle</button>
</div>
</template> <script>
export default {
data () {
return {
isPartA: true
}
},
methods: {
toggle () {
this.isPartA = !this.isPartA
}
}
}
</script> <style>
html {
height: 100%;
}
</style>

点击按钮前

点击按钮后

v-if和v-show区别:

  • v-if删除
  • v-show用css控制

v-if、v-else

<template>
<div>
<a v-if="isPartA">partA</a>
<a v-else>no data</a>
<button v-on:click="toggle">toggle</button>
</div>
</template> <script>
export default {
data () {
return {
isPartA: true
}
},
methods: {
toggle () {
this.isPartA = !this.isPartA
}
}
}
</script> <style>
html {
height: 100%;
}
</style>

点击按钮前

点击按钮后

最新文章

  1. 时隔一年再读到the star
  2. W3School-CSS 伪元素 (Pseudo-elements) 实例
  3. sql里面的分页
  4. IOS开发技巧快速生成二维码
  5. javascript设计模式实践之代理模式--图片预加载
  6. 【leetcode】Single Number II (medium) ★ 自己没做出来....
  7. qt QMetaObject::connectSlotsByName()自动关联失效问题解决
  8. Python函数中的参数(二)
  9. Java Interface是存放常量的最好地方吗?(转)
  10. iOS 跳转到应用所在的App Store市场
  11. DBCONN
  12. 【HDOJ】1271 整数对
  13. Android 常用开源代码整理
  14. 物联网操作系统HelloX开发人员入门指南
  15. Ueditor文件上传问题
  16. js中常用的日期总结
  17. VS2012 发布网站步骤
  18. win10连接无线网,开启移动热点,手机连接它手机一直显示获取ip地址中。
  19. uoj#209. 【UER #6】票数统计
  20. [Unity基础]RenderTexture

热门文章

  1. 【CV】ICCV2015_Describing Videos by Exploiting Temporal Structure
  2. 2-Twenty third Scrum Meeting-20151229
  3. how are you
  4. python中的文件读写(open()函数、with open(&#39;file_directory&#39;,&#39;r&#39;) as f:、read()函数等)
  5. HTML 5 Canvas vs. SVG
  6. ThinkPad E470 win10,重装win10专业版后无声音
  7. python中Switch/Case实现
  8. hive视图
  9. rabbitmq代码配置
  10. Java之JSON操作(gson)