vue 锚点跳转防止路径变化后,刷新页面报错的问题
<ul class="product-title"> <template v-for="item in list.titleList"> <li :class="{'active': item.id === tId }" :key="item.id" @click="clickTitle(item, item.id)">{{item.name}}</li> </template>
</ul>
methods: {
clickTitle(i, id) {
this.tId = id
document.querySelector(i.href).scrollIntoView(true)
}
}