目前前端框架太多,接触过angular、ember,现在开始倒腾vue
此处用到v-if、v-else、v-show,v-if或让元素不在dom上,v-show只是改变display:block属性,感觉v-if好
感觉跟适合、
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>v-if、v-else、v-show</title> <script src="../js/vue.js"></script> <!--copy from http://vuejs.org.cn/guide/--> </head> <body> <div id="app"> <p v-if="willshow">显示显示显示</p> <p v-else>隐藏隐藏隐藏隐藏</p> <button @click="fn()">改变</button> </div> <script> var vm=new vue({ el:"#app", data:{ willshow:true }, methods:{ fn:function(){ if(this.willshow==true){ this.willshow=false; }else{ this.willshow=true } } } }); </script> </body> </html>
以上这篇vuejs简单的点击显示与隐藏的效果【实现代码】就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。
如对本文有疑问, 点击进行留言回复!!
vue 动态设置img的src地址无效,npm run build 后找不到文件的解决
解决vue动态路由异步加载import组件,加载不到module的问题
解决vue的router组件component在import时不能使用变量问题
Vue中的this.$options.data()和this.$data用法说明
GBase 8a MPP Cluster使用Ceph做存储计算分离
网友评论