这个是 vertical.vue (中间放数组数据的)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | < template > < div class = "vertical" ref = "scroll_item" > < div > < div > < ul > < li v-for = '(item, index) in list' :key = 'index' > < div class = "icon" > < img width = "60" height = "60" :src = "item.img" > </ div > < div class = "text" > < span >{{item.name}}</ span > </ div > </ li > </ ul > </ div > </ div > </ div > </ template > < script > import BScroll from 'better-scroll' export default { name: 'horizontal', data () { return { list: [ { 'img': '../static/list/1.jpg', 'name': '联想(Lenovo)拯救者R720' }, { 'img': '../static/list/2.jpg', 'name': '小米(MI)Pro 15.6英寸' }, { 'img': '../static/list/3.jpg', 'name': '联想(Lenovo)小新潮7000 13.3英寸' }, { 'img': '../static/list/4.jpg', 'name': '戴尔DELL灵越游匣GTX1050 15.6英寸' }, { 'img': '../static/list/5.jpg', 'name': '华硕(ASUS) 飞行堡垒四代FX63VD 15.6英寸' }, { 'img': '../static/list/6.jpg', 'name': '联想(Lenovo)拯救者R720 15.6英寸' }, { 'img': '../static/list/7.jpg', 'name': '戴尔DELL成就5000不凡银13.3英寸' }, { 'img': '../static/list/8.jpg', 'name': '小米(MI)Air 13.3英寸金属' }, { 'img': '../static/list/9.jpg', 'name': '联想ThinkPad 翼480(0VCD)14英寸' }, { 'img': '../static/list/10.jpg', 'name': '联想(Lenovo)拯救者R720 15.6英寸' } ] } }, methods: { _initS () { console.log('start') let scroll = new BScroll(this.$refs.scroll_item, { scrollY: true, click: false, probeType: 3 }) scroll.on('scroll', (pos) => { console.log(`Now position is x: ${pos.x}, y: ${pos.y}`) }) } }, created () { this.$nextTick(() => { setTimeout(() => { this._initS() }, 20) }) } } </ script > |
他的父组件是
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | < template > < div > < div class = "header" > < h2 >better-scroll 范例</ h2 > </ div > < div class = "tab" style = "height: 44px;line-height: 44px" > < router-link class = "text-align: center" to = "/horizontal" > < span class = "padding-bottom: 5px" >横向滚动</ span > </ router-link > < router-link class = "text-align: center" to = "/vertical" > < span class = "padding-bottom: 5px" >纵向滚动</ span > </ router-link > </ div > </ div > </ template > |
为什么联通父组件也一起滚动了啊