Vue.js页面验证跳转功能实现
作者:W少年没有乌托邦
这篇文章主要介绍了Vue.js页面验证跳转功能实现,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧
效果图
代码:
new.html
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <div id="app"> <input type="text" name="" id="" v-model="userName"/><br> <input type="text" name="" id="" v-model="pwd"/><br> <button @click="cha()">跳转</button> </div> <script src="js/vue.js"></script> <script> var vm=new Vue({ el:"#app", data:{ userName:"1", pwd:"2" }, methods:{ cha:function(){ if (this.userName=="admin"&&this.pwd=="123456") { location.href="./Seek.html" rel="external nofollow" } else{ console.log("登录失败") } } } }) </script> </body> </html>
seek.html
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <h1>异兽信息列表</h1> <div id="app"> <input type="text" name="" id="" v-model="keyword"> <table border="1"> <tr> <th>编号</th> <th>名称</th> <th>攻击力</th> <th>简介</th> </tr> <tr v-for="(item,index) in relist.length>0?relist:shou" > <td>{{item.id}}</td> <td>{{item.name}}</td> <td>{{item.gongjili}}</td> <td>{{item.jianjie}}</td> </tr> </table> </div> <script src="js/vue.js"></script> <script> var Vue=new Vue({ el:"#app", data:{ keyword:"", relist:[], shou:[{ id:1, name:"困", gongjili:12, jianjie:"困是打怪兽" }, { id:2, name:"食铁兽", gongjili:123, jianjie:"驱蚊器二群无的群多无群无多" }, { id:3, name:"困", gongjili:1234, jianjie:"15气温气温气温耳热与法国代购" } ] }, watch:{ keyword:function(newVal,oldVal){ var ret =this.shou.filter(m=>m.name.toString().includes(newVal.toString())); this.relist=ret; } } }) </script> </body> </html>
到此这篇关于Vue.js高效前端开发(页面验证跳转,查)的文章就介绍到这了,更多相关Vue.js页面验证跳转内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!