Vue/ts --this.$refs.form.resetFields();表单提示调用方法错误
作者:互联网
错误提示:
Property 'resetFields' does not exist on type 'Vue | Element | Vue[] | Element[]'.
Property 'resetFields' does not exist on type 'Vue'.
官网连接: https://class-component.vuejs.org/guide/refs-type-extension.html
<template>
<input ref="input">
</template>
<script lang="ts">
import Vue from 'vue'
import Component from 'vue-class-component'
@Component
export default class InputFocus extends Vue {
// annotate refs type.
// The symbol `!` (definite assignment assertion)
// is needed to get rid of compilation error.
$refs!: {
input: HTMLInputElement
}
mounted() {
// Use `input` ref without type cast.
this.$refs.input.focus()
}
}
</script>
标签:Vue,form,--,resetFields,refs,input,type,class 来源: https://www.cnblogs.com/smallyi/p/14255386.html