Conditional rendering in Vue.js
P粉919464207
P粉919464207 2023-09-15 16:24:26
0
1
508

My application loops through a list of vegetable crops and displays disease keys and links to control measures for each crop.

For one of the crops (cropid=6), no disease key exists and I cannot stop showing that specific link.

The relevant parts of my code are as follows:

   

Diseases

My data part is as follows:

diseases: [ { link: "disease key", id: "k", path: "key" }, { link: "disease controls", id: "d", path: "control" }, ],

How do I stop displaying the "disease key" link if cropID=6?

Thank you/Tom

P粉919464207
P粉919464207

reply all (1)
P粉713846879

For conditional display, you need to usev-if. Assumingdisease.idis similar tocropId, you can use the following code:

var app = new Vue({ el: '#app', data: { diseases: [{ link: "disease key", id: "k", path: "key" }, { link: "disease controls", id: "d", path: "control" }, ] } })
   

Diseases

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!