wenkang lin
wenkang lin

Reputation: 129

how to use the instanceof operator to check parameter type in props data?

in vue guide doc, I have looked at the documentation about prop validation :

The type can be one of the following native constructors:

String

Number

Boolean

Function

Object

Array

In addition, type can also be a custom constructor function and the assertion will be made with an instanceof check.

so, how can I use the instanceof operator to achieve parameter custom type checking ?

Upvotes: 2

Views: 1775

Answers (1)

wenkang lin
wenkang lin

Reputation: 129

you can use custom type like:

props: {
  file: { type: File, required: true }
}

Upvotes: 1

Related Questions