After the vue dynamic component tab is switched, how to realize the navigation highlight problem?

as shown in the figure, the tab switch using the dynamic components of vue now wants to highlight the navigation! Click to log in and highlight the display, the registration highlight is invalid, and vice versa.

Code:

    <div class="title">
        <span @click="toggleTab("log")"></span>
        <span></span>
        <span @click="toggleTab("reg")"></span>
    </div>
    <div>
        <keep-alive>
            <component :is="flag"></component>    
        </keep-alive>
    </div>

      export default {
          data(){
              return{
                  flag:"reg",
              }
          },
          components:{
              reg,
              log
          },
        methods: {
          toggleTab: function(index) {
           this.flag = index;     
          },
        }
      }          

was intended to be written in a loop, but it was found that after the implementation was highlighted, the dynamic components could not be displayed. Is there any good way to solve it?

<span v-for="(item,index) in menu" v-bind:class="{"on":flag==index}" v-on:click="toggleTab(index)">{{item.name}}</span>        
Mar.18,2021

vuex manages highlighted index

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb67b5-25e0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb67b5-25e0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?