试过在#letter里加反斜杠#号可以正常描点,但是其他锚点就不可了...
<div id="box">
<div style="width: 500px;">
<div style="float: right;font-size: 24px;">
<div v-for="(keys , index) in letterText" :key="index">
<a href="javascript:;" @click="onLetter('#letter'+ keys)">{{keys}}</a>
</div>
</div>
<div v-for="(items, keys ,index) in letter" :key="keys" style="margin-top: 300px;color: #fd0000;font-size: 24px;">
<div :id="'letter'+ keys">{{keys}}</div>
</div>
</div>
</div>
methods: {
onLetter(keys) {
let letter = this.$el.querySelector(keys)
document.body.scrollTop = letter.offsetTop
}
},
});
相关分类