Vuejs typescript this.$refs..value does not exist

前端 未结 7 1461
野的像风
野的像风 2020-11-30 13:33

While rewriting my VueJs project in typescript, I came across a TypeScript error.

This is a part of the component that has a custom v-model.

An input field i

7条回答
  •  隐瞒了意图╮
    2020-11-30 14:04

    You can do this:

    class YourComponent extends Vue {
      $refs!: {
        checkboxElement: HTMLFormElement
      }
    
      someMethod () {
        this.$refs.checkboxElement.checked
      }
    }
    

    From this issue: https://github.com/vuejs/vue-class-component/issues/94

提交回复
热议问题