vue manually refreshes the page after clicking the anchor point, showing blank

1. After the a tag anchor link is manually refreshed, the page displays blank.

   <li
       v-for="(item, index) in listTow2"
              :key="index"
              :class="{ current: index == isActive2 }"
              @click="check(index)"
            >
              <div class="yinying">
                <a  style="
                  " :href="'#' + item.pus">  {
   
   { item.name }}</a></div>
                 
            </li>
             //  :href=" '#' + item.pus"   要加上一个#

2.js

  data() {
    return {
      listTow2: [
        { name: "公告通知", pus: "#anchor_0" },
        { name: "检测服务", pus: "#anchor_1" },
        { name: "报告服务" , pus: "#anchor_2"},
        { name: "检测机构" , pus: "#anchor_3"},
        { name: "客户服务" , pus: "#anchor_4"},
      ],
     
    };
  },

3. The id of html should also be written dynamically

 <div :id="listTow2[0].pus"></div>
 <div :id="listTow2[1].pus"></div>
 <div :id="listTow2[2].pus"></div>
 <div :id="listTow2[3].pus"></div>
 <div :id="listTow2[4].pus"></div>

4. Refreshing the URL in the address bar of the page will also disappear.

Insert image description here
Insert image description here
Insert image description here

Guess you like

Origin blog.csdn.net/weixin_53587375/article/details/120270380