Live2d Test Env

vue 锚链接

min.js

1 Vue.directive('anchor', { // 锚链接自定义指令
2     inserted: function (el, binding) {
3         el.onclick = function () {
4             document.documentElement.scrollTop = $('#anchor-' + binding.value).offset().top
5         }
6     }
7 });

xxx.vue

1 <template>
2     <div class="modular1" v-anchor="index" v-for="(item,index) in $t('producTmodulArr')" :key="index">
3       <div class="modularImg">
4         <img :src="item.url" alt="" width="108" height="98">
5       </div>
6       <div class="modularText"><p>{{item.text}}</p></div>
7     </div>
8 </template>

 

posted @ 2019-11-28 09:09  小猪(朱)  阅读(308)  评论(0编辑  收藏  举报