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

759 Views Asked by At

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

1

There are 1 best solutions below

0
On BEST ANSWER

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>()