C
C
Comnox2021-09-16 10:36:53
typescript
Comnox, 2021-09-16 10:36:53

Why does the error "Property 'toLowerCase' does not exist on type 'Ref'" occur?

I ran into such a problem that when rewriting a component in
Vue 3 on the Composition API in the watch -er, an error appeared:

Property 'toLowerCase' does not exist on type 'Ref<string>'

, although logically everything is correct.

seachCityName - const seachCityName = ref("") (plain string)
fullListofCities - an array of ObjectOfCity:
interface ObjectOfCity {
  city: string;
  temperature: number;
}

watch -er itself :

watch(seachCityName, () => {
    store.commit(
      "SET_CITIES",
      store.getters.fullListofCities.filter((city: ObjectOfCity) =>
        city.city.toLowerCase().includes(seachCityName.toLowerCase())
   )
 );
})


6142f3231f022200208233.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-09-16
@Comnox

seaCityName - regular string

Yah? Judging by the text of the error, this is ref. So your string will be seachCityName.value.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question