1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > vue 横向菜单滚动定位_使用vue组件+iscroll实现一个横向菜单 不能正确滑动

vue 横向菜单滚动定位_使用vue组件+iscroll实现一个横向菜单 不能正确滑动

时间:2021-10-24 14:24:26

相关推荐

vue 横向菜单滚动定位_使用vue组件+iscroll实现一个横向菜单 不能正确滑动

使用vue组件+iscroll实现一个横向菜单,可是却不能滑动,给父元素ul写死一个宽度可以滑动。

但是,我在computed里计算宽度,直接路由进去不能滑动,当我进入别的组件(切换路由)回来又可以滑动了

示例地址:http://onepoint./news/1

{{item.name}}

#wrapper{

position: absolute;

z-index: 1;

height: 40px;

left: 0;

width: 100%;

overflow: hidden;

}

#scroller{

position: absolute;

z-index: 1;

-webkit-tap-highlight-color: rgba(0,0,0,0);

}

#scroller ul{

width: 100%;

height: 100%;

text-align: center;

}

#scroller li{

float:left;

height: 30px;

line-height: 30px;

width:1.6rem;

list-style-type: none;

}

#scroller .bot{

border-bottom:2px solid rgb(37, 190, 169);

}

import IScroll from 'iscroll/build/iscroll-lite.js'

export default{

props: {

menu: {

type: Array

},

selected: {

type: Boolean,

require: false,

default: false

}

},

data () {

return {

index: 0

}

},

computed: {

getWidth () {

return 'width:' + this.menu.length * 1.6 + 'rem'

}

},

ready () {

var myScroll = new IScroll(this.$els.wrapper, {scrollX: true, scrollY: false})

myScroll.say = ''

},

methods: {

checkIt (index, item) {

var lis = this.$els.ul.children

lis[this.index].classList.remove('bot')

this.index = index

lis[index].classList.add('bot')

this.$dispatch('click-msg', item)

}

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。