1. 程式人生 > >vue:非同步async and await與this.nextTick()的使用

vue:非同步async and await與this.nextTick()的使用

專案例子:

async focusInput (index) {
  await this.$nextTick(() => {
    let el = this.$refs[`scopeInput-${index}`].$el
    let input = el.querySelector('.el-input__inner')
    input.focus()
  })
},

<el-input
  @blur="blurInput"
  @keyup.native="enterInput"
  :ref="`scopeInput-${scope.$index}`"
  v-model="coursePrice"
  size="small">
</el-input>