Closed YanDevDe closed 3 years ago
Use a declare
in front of $refs
will solve your problem.
<script lang="ts">
import { Vue, Options } from 'vue-class-component';
@Options({
components: {},
})
export default class LoginPage extends Vue {
// annotate refs type.
declare $refs: {
input: HTMLInputElement;
};
mounted() {
// Use `input` ref without type cast.
this.$refs.input.focus();
}
}
</script>
That worked out! Thank you so much @nick-ma :)
Hello everyone!
I was trying to use
$refs
inApp.vue
under vue-class-component 8.0.0-rc1 with TypeScript, but for some reason, using this inside of classcaused following error:
I'm using Vue 3.1.4 (per vue-cli), my tsconfig.json is:
Am I doing something wrong here?
Wish you a great day!
Yan