当滚动列表的时候,让input框失去焦点(移动端会收起键盘)

1.拓展scroll.vue事件

 1    beforeScroll:{
 2          type:Boolean,
 3          default:false
 4         }
 5 
 6 
 7   if(this.beforeScroll){//滚动列表的时候收起键盘(移动端)
 8             this.scroll.on('beforeScrollStart',()=>{
 9               this.$emit('beforeScroll')
10             })
11           }

2.在suggest.vue里声明beforeScrll:true,并$emit(beforeScroll)事件

1  beforeScroll(){
2           this.$emit('beforeScroll')
3         },

3.在搜索input框中写失去焦点事件:

1   blur(){
2             this.$refs.query.blur()
3           },

4.在search.vue父组件中调用子组件的blur方法;

1 blurInput(){
2             this.$refs.searchBox.blur()
3         },

猜你喜欢

转载自www.cnblogs.com/yangguoe/p/9474836.html