导航栏点击高亮,为什么我用了几种办法都不能成功切换背景??


<template>
  <div class="heard1">
      <div class="heard">
        <div class="heard-item-l">
          <img src="../../../static/image/logo.png" alt="" srcset="">
          <div>
            <div style="font-weight: 700; letter-spacing: 7.5px;">广州稚宇技术有限公司</div>
            <div style="font-size: 9px;">Guangzhou Zhiyu Technology Co. , Ltd.</div>
          </div>
        </div>
        <router-link class="heard-item-ss" to="/">首页</router-link>
        <router-link class="heard-item-s" to="/About">产品研发</router-link>
        <router-link class="heard-item-s" to="/commerce">解决方案</router-link>
        <router-link class="heard-item-s" to="/case/case">合作案例</router-link>
        <router-link class="heard-item-s" to="/Aboutus">关于我们</router-link>
        
        <!-- <router-link :class="{'heard-item-ss': 0 == isActive}" class="heard-item-s" @click="change(0)" to="/">首页</router-link> -->
        <!-- <router-link :class="{'heard-item-ss': 1 == isActive}" class="heard-item-s" @click="change(1)" to="/About">产品研发</router-link> -->
        <!-- <router-link :class="{'heard-item-ss': 2 == isActive}" class="heard-item-s" @click="change(2)" to="/commerce">解决方案</router-link> -->
        <!-- <router-link :class="{'heard-item-ss': 3 == isActive}" class="heard-item-s" @click="change(3)" to="/case/case">合作案例</router-link> -->
        <!-- <router-link :class="{'heard-item-ss': 4 == isActive}" class="heard-item-s" @click="change(4)" to="/Aboutus">关于我们</router-link> -->
        <!-- 搜索框 -->
        <div class="heard-item-r">
          <div>
            <input type="text" placeholder="请输入内容">
            <i class="a"></i>
          </div> 
        </div>
      </div>
    </div>
</template>
<script>
export default {
  data() {
    return {
      isActive: 0,
      list: [
        {name:"首页"},
        {name:"产品研发"},
        {name:"3"},
        {name:"4"},
        {name:"5"},
      ]
    }
  },
  methods: {
    change (e) {
      // var a = document.getElementsByClassName('.heard-item-s');
      var isActive = 0;
      // for (var i=0;i < a.length; a++) {
        this.isActive = e;
        // console.log(item)
      // }
    }
  }
  // components: 'heard', 
}
var e = document.getElementsByTagName("router-link");
var i,j;
var length = e.length;
for (i=0;i<length;i++){
  e[i].onclick=function() {
    alert(111)
    for(j=0;j<length;j++) {
      e[j].className="heard-item-s";
    }
    this.className+= "heard-item-ss";
  }
}

</script>

<style lang="scss" scoped>
.heard1 {
    width: 100%;
    height: 80px;
    background-image: url("../../../static/image/rectangle.png");
    position: absolute;
    z-index: 500;
    .heard {
      width: 78%;
      height: 80px;
      display: flex;
      font-size: 14px;
      margin-left: 12%;
      .heard-item-l {
        min-width: 300px;
        width: 426px;
        height: 45px;
        display: flex;
        flex-direction: row;
        color: #224FA8;
        padding-top: 24px;
        font-family: PingFangSC-Semibold, PingFang SC;
        img {
          width: 33px;
          height: 33px;
        }
      }
      .heard-item-s {
        min-width: 100px;
        width: 7.81%;
        height: 68.75%;
        margin-top: 25px;
        line-height: 28px;
        font-weight: 500;
        color: #333;
        text-decoration: none;
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
      }
      .heard-item-ss {
        background: #224FA8;
        min-width: 100px;
        width: 7.81%;
        height: 68.75%;
        margin-top: 25px;
        line-height: 28px;
        font-weight: 500;
        color: #FFF;
        text-decoration: none;
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
      }
      .heard-item-r {
        flex: 1;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        div {
          position: relative;
          input {
            width: 139px;
            height: 26px;
            // margin: 24px 0 0 130px;
            border-radius: 18px;
            border: 2px solid rgba(94, 93, 93, 0.39);
            outline:none;
            text-indent: 10px;
            border-radius: 18px;
            background-color: transparent;
          }
          .a {
            background: url(../../../static/icon/search.png);
            background-repeat: no-repeat;
            background-size: contain;
            width: 12px;
            height: 12px;
            position: absolute;
            top: 10px;
            right: 10px;
          }   
        }
      }
    }
} 
</style>

都vue,原生都不怎么合适了
vue自带的导航高亮,在css里面写

.router-link-active{
  background: red;
}

第一种是原生js,第二种是vue框架写的,也没实现,我是菜鸟求教!

img