Vuejs搜尋下拉框

來源:互聯網
上載者:User

標籤:show   app   min   cti   []   hang   vuejs   bootstrap   head   

 

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">  <link href="../../plugins/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet" type="text/css">  <script src="./vue.js"></script>  <script src="./vue-resource.js"></script>  <script src="../../plugins/jquery-1.9.1.min.js"></script>  <script src="../../plugins/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>  <title>Vuejs2.0 demo</title>    <title>Title</title>  <style type="text/css">    .gray{      background:red;    }  </style></head><body><div id="app">  <input type="text" value="{{keyword}}" class="form-control" v-model="keyword"  @keyup="get($event);" @keydown.down="changeDown()"  @keydown.up="changeUp()">  <ul>    <li v-for="(value,index) in mydata" :class="{gray:index==now}">       {{value}}    </li>  </ul>  <p v-show="mydata.length==0">暫無資料...</p></div><script>  window.onload =function(){    var mv = new Vue({      el:"#app",      data:{        mydata:[],        keyword:"",        now:-1      },      methods:{        get:function (ev) {          if(ev.keyCode==38  || ev.keyCode==40){            return false;          }          this.$http.jsonp("https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su",{wd:this.keyword},{jsonp:"cb"}).then(function(res){                this.mydata = res.data.s;                 console.log("成功");          },function(){                 console.log("失敗");          });        },        changeDown:function(){          this.now++;          if(this.now==this.mydata.length){            this.now = -1;          }          this.keyword = this.mydata[this.now];        },        changeUp:function(){          this.now--;          if(this.now==-2){            this.now = this.mydata.length-1;          }          this.keyword = this.mydata[this.now];        }      }    });  };</script></body></html>

 

Vuejs搜尋下拉框

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.