vue.$nextTick 在手机端没法input.focus()

<div id="app">vue

  <input ref="input1" v-show="showInput">app

  <input ref="input2">this

  <button @click="fn">按钮</button>.net

</div>input

  var app = new Vue({cli

  el:"#app",next

  data:{di

    showInput:false手机端

  }data

  methods:{

    fn(){

    this.$refs.input2.focus()       //这个始终显示的input 能够实现手机端pc端focus

    this.showInput = true

    this.$nextTick(()=>{

    this.$refs.input1.focus()      //这个经过点击控制显示的input 在pc能够实现focus,手机端无效

    })

  }

})

这里有线上演示
http://jsfiddle.net/jfk35hp2/7/

  最后发现是vue版本问题 ,退到2.3.4版本及好了,新版本更新了什么东西致使的暂时还不清楚

相关文章
相关标签/搜索