日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

vue案例_百度搜索下拉菜单

發(fā)布時間:2024/1/3 综合教程 24 生活家
生活随笔 收集整理的這篇文章主要介紹了 vue案例_百度搜索下拉菜单 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>百度下拉菜單</title>
 6     <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
 7     <meta name="apple-mobile-web-app-capable" content="yes">
 8     <meta name="apple-mobile-web-app-status-bar-style" content="black">
 9     <style>
10         .gray{
11             background: rebeccapurple;
12         }
13     </style>
14     <script src="vue.js"></script>
15     <script src="vue-resource.js"></script>
16     <script>
17         window.onload=function(){
18             new Vue({
19                 el:'body',
20                 data:{
21                     myData:[],
22                     t1:'',
23                     now:-1
24                 },
25                 methods:{
26                     get:function(ev){
27                         if(ev.keyCode==38 || ev.keyCode==40)return;
28 
29                         if(ev.keyCode==13){
30                             window.open('https://www.baidu.com/s?wd='+this.t1);
31                             this.t1='';
32                         }
33 
34                         this.$http.jsonp('https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su',{
35                             wd:this.t1
36                         },{
37                             jsonp:'cb'
38                         }).then(function(res){
39                             this.myData=res.data.s;
40                         },function(){
41 
42                         });
43                     },
44                     //下翻
45                     changeDown:function(){
46                         this.now++;
47                         if(this.now==this.myData.length)this.now=-1;
48                         this.t1=this.myData[this.now];
49                     },
50                     //上翻
51                     changeUp:function(){
52                         this.now--;
53                         if(this.now==-2)this.now=this.myData.length-1;
54                         this.t1=this.myData[this.now];
55                     }
56                 }
57             });
58         };
59     </script>
60 </head>
61 <body>
62 <div id="box">
63     <input type="text" v-model="t1" @keyup="get($event)" @keydown.down="changeDown()" @keydown.up.prevent="changeUp()">
64     <ul>
65         <li v-for="value in myData" :class="{gray:$index==now}">
66             {{value}}
67         </li>
68     </ul>
69     <p v-show="myData.length==0">暫無數(shù)據(jù)...</p>
70 </div>
71 </body>
72 </html>

實現(xiàn)百度搜索下拉菜單,對接口的理解

總結

以上是生活随笔為你收集整理的vue案例_百度搜索下拉菜单的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。