shunze.chen
shunze.chen

Reputation: 359

how to define ref data as class type in vue3 with ts

I want to use ref to create a class . It can be used as a class instance which can be called by .

in my ts file

export default declare class Cropper {
  ....
}

in my vue3 file

const cropper =ref<Cropper||undefined||null>()

but it dosen't work enter image description here

Upvotes: 2

Views: 911

Answers (1)

Estus Flask
Estus Flask

Reputation: 222474

The syntax for | union types in TypeScript isn't the same as || (logical OR) in JavaScript.

It should be:

const cropper = ref<Cropper|undefined|null>()

Upvotes: 2

Related Questions