D
D
Daria It doesn't matter2021-06-29 16:28:41
Vue.js
Daria It doesn't matter, 2021-06-29 16:28:41

Is it possible to make a condition in?

Hello!
the project has a block in which items with links are displayed

<router-link :to="{name:'Product', params: {pathMatch: item.url_path}}" v-masonry-tile class="item" :key="index" v-for="(item, index) in items">
          <img :src="item.image"  alt="" />
          <span>{{ item.title }}</span>
        </router-link>

this link is filled with json that comes from a back
like this
image_url:"files/cONfDCGaALYzbyreAn176wc3ViG8s9EhdQxkIaCh.png"
title:"Sport"
url:"http://sandbox-canvas/catalog/best-of-june"
url_path:"best-of-june"
url_type:"catalog"

url_type can be product, or maybe catalog
I wanted to know if it is possible to make some condition in :to="..." that will look at url_type and if it is catalog then take name: 'catalog', and if product then name: 'product'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2021-06-29
@ex123

Something like that?

:to="{name: item.url_type, params: {pathMatch: item.url_path}}"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question