S
S
SM_ST2022-01-12 14:02:53
typescript
SM_ST, 2022-01-12 14:02:53

How to fix Vue + TypeScript error?

form.categoryId = computed(() => {
    return storeCategory.getSelectedCategory.id;
  });


Gives this error

(property) categoryId: number
Тип "ComputedRef<number>" не может быть назначен для типа "number"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2022-01-12
@SM_ST

What do you not understand from the description of the error?
You are trying to assign the object ComputedRef<number>returned by the computed function to an object field declared as number.
You need to either change the type of the field, or update the field through watch.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question