vue中,實現錨點定位及跳轉過渡效果


<ul class="filter-nav">
      <li
        v-for="(item, index) in filterNavItem"
        class="filter-nav-item"
        :class="{ active: index == filterNavItemActive }"
        :data-target="item.target"
        @click="returnIdAddress('#' + item.target, index)"
      >
        {{ item.name }}
      </li>
    </ul>
 data() {
    return {
      filterNavItem: [
          { target: "team", name: "隊員" },
          { target: "alarm", name: "事件" },
          { target: "car", name: "車輛" },
          { target: "patrol", name: "巡更點" }
      ],
      filterNavItemActive: 0,
    };
  },
returnIdAddress(id, index) {
      document.querySelector(id).scrollIntoView({
        behavior: "smooth"
      });
      this.filterNavItemActive = index;
    },


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM