0

I'm having a great deal of trouble with my Vue component.

<script lang="ts">
import Vue from 'vue';
import { ElForm } from 'element-ui/types/form';

type Validator = (
  this: typeof PasswordReset,
  rule: any,
  value: any,
  callback: (error?: Error) => void
) => void;

const validatePass1: Validator = function(rule, value, callback) {
  if (value && this.form.passwordConfirm) {
    (this.$refs.form as ElForm).validateField('passwordConfirm', valid => {});
  }
};

const PasswordReset = Vue.extend({
  // ...

In the validatePass1 func, this.form is underlined as an error, as is this.$refs. Respectively:

"Property 'form' does not exist on type 'VueConstructor<{ form: { password: string; passwordConfirm: string; }; rules: { password: ({ requ...'."

"Property '$refs' does not exist on type 'VueConstructor<{ form: { password: string; passwordConfirm: string; }; rules: { password: ({ requ...'."

How do I get this function to recognize refs/props/data attached to my component?

1 Answer 1

1

you can instantiate vue globally,

window.vm = new Vue ({...});

and referencing it anywhere in your ts file like

window.vm.$refs.form
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.