Vuetify's autofocus works only on first modal open

后端 未结 2 1634
情深已故
情深已故 2021-01-01 17:58

I am trying to use Vuetify\'s v-text-field autofocus however it works only first time. After I close the dialog, it doesn\'t work anymore.

2条回答
  •  感动是毒
    2021-01-01 18:43

    In your sandbox (but also seems to be the case in your question) you had an error in your code, you removed return from the provided workaround:

    watch: {
      dialog (val) {
        if (!val) return; // you removed `return` here
        requestAnimationFrame(() => {
          return this.$refs.focus.focus();
        }
      });
    

    So actually it works

提交回复
热议问题