vue 显隐操作

编程入门 行业动态 更新时间:2024-10-27 18:18:58

vue 显隐<a href=https://www.elefans.com/category/jswz/34/1770947.html style=操作"/>

vue 显隐操作

vue 显隐操作

1、v-if 实现显隐

(1)、显示
<template><div><button @click="btn">显示</button><h1 v-if="if_show">点击显示之后显示的内容</h1></div>
</template><script>expert default{data(){return{if_show:false,}},methods:{btn(){this.if_show = true;}}}
</script><style scope>
</style>
(2)、隐藏
<template><div><button @click="btn">隐藏</button><h1 v-if="if_show">点击隐藏之后,需要隐藏的内容</h1></div>
</template><script>expert default{data(){return{if_show:true,}},methods:{btn(){this.if_show = false;}}}
</script><style scope>
</style>
(3)、显隐
<template><div><button @click="btn">隐藏</button><h1 v-if="if_show">点击隐藏之后,需要隐藏的内容</h1></div>
</template><script>expert default{data(){return{if_show:true,}},methods:{btn(){this.if_show = !this.if_show;}}}
</script><style scope>
</style>

v-showd的显隐操作和v-if一样

更多推荐

vue 显隐操作

本文发布于:2023-07-28 15:43:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1239022.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:操作   vue

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!