V
V
VegasChickiChicki2019-09-29 15:51:42
JavaScript
VegasChickiChicki, 2019-09-29 15:51:42

How to write such a condition?

I want to display the component, provided that the current path does not have "/page_basket" in it, but it may be that after and before this part of the path there will be something else.
For example:

/page_basket/test // должно равняться false
test/test2 // должно равняться true
/test/page_basket/  //должно равняться false

And so on, that is, check the occurrence of /page_basket in the address, now only this way: And when something is superfluous, then such a condition does not work (and should not), so I wanted to know how to write a condition that satisfies wrote out.
v-if="$nuxt.$route.path !== '/page_basket'"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Sartakov, 2019-09-29
@VegasChickiChicki

v-if="$nuxt.$route.path.indexOf( '/page_basket') === -1"

v-if="!$nuxt.$route.path.includes( '/page_basket')"

A
Anton Neverov, 2019-09-29
@TTATPuOT

function f(url) {
  url = url.toLocaleLowerCase();
  return !url.includes('/page_basket');
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question