点击输入框的时候页面顶上去

1.输入框写入@focus.Native="focus($event)"事件
<input @focus.Native="focus($event)" v-model="phone" type="number" placeholder="请输入手机号" @input="phoneInput">
2.
// 设置手机输入框(点击输入顶上去)
focus(ev){
this.scrollIntoView(ev.target);
},
//点击输入顶上去
scrollIntoView(target){
const u = navigator.userAgent;
const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
let facility = isiOS?true:false;
if(!facility){
setTimeout(()=>{
target.scrollIntoView()
},500)
}
},
posted @ 2018-05-24 14:22  米牙  阅读(502)  评论(0编辑  收藏  举报