&"> Change image icon when active tab changes-PHP Chinese Network Q&A
Change image icon when active tab changes
P粉448130258
P粉448130258 2023-08-29 18:55:29
0
1
508

Currently I have a v-tab that has four tabs with image icons and text. However, when the tab is active, the active tab icon should change to another image. what should I do?

   {{ item.name }}   data() { return { tabs: null, items: [ { icon: "/planeInactive.svg", name: "plane" }, { icon: "/hotelInactive.svg", name: "hotel" }, { icon: "/planehotelInactive.svg", name: "plane hotel" }, { icon: "/planeInactive.svg", name: "students" }, ], }; },

P粉448130258
P粉448130258

reply all (1)
P粉413704245
  1. Use some default values for yourv-modeland'tab'make the tab active by default. (I'm using the tab's name attribute inv-model, but you can use any unique attribute you want.)
  2. Use thisv-modelto check which tab is active and update the icon using conditional operators. (I used dummy icons, you can use yours.)

In this demo, you should see that when the tab is active, a colored flight icon will be displayed, otherwise a black flight icon will be displayed.

       
{{ item.name }}
    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!