better-scroll使用

<template>
    <div>
         //滚动视图的父容器,使用定位固定位置 overflow:hiden
         <div class="goods">
           //滚动视图ref 使用better-scroll初始化
           <div class="menu-wrapper" ref="menuWrappers">
                <ul>
                    <li class="menu-item"
                        ref="menuList"
                        v-for="good in goods">
                        <span class="text">{{good.name}}</span>
                    </li>
                </ul>
            </div>
            <div class="food-wrapper">

            </div>
        </div>
    </div>
</template>
<script>
    import order_data from '../../../static/js/orderData'
    import BScroll from 'better-scroll'
    export default {
        data:function () {
          return {
              goods: [],
              listHeight: [],
              scrollY: 0,
              selectedFood: {}
          }
        },
        created:function () {
            console.log(order_data)
            this.goods = order_data.goods;

            this.$nextTick(() => {
               this._initScroll();
            });
        },
        methods:{
            _initScroll:function () {
                this.meunScroll = new BScroll(this.$refs.menuWrappers, {
                    click: true
                });
            }
        }
    }
</script>
<style>
    .goods{
        display: flex;
        position: absolute;
        top: 4px;
        bottom: 50px;
        width: 100%;
        overflow: hidden;
    }
    .goods .menu-wrapper{
        flex: 0 0 80px;
        width: 80px;
        background:#f3f5f7;
    }
    .goods .menu-item{
        display: table;
        height: 50px;
        width: 56px;
        margin-left: 12px;
        line-height: 14px;
    }
    .goods .menu-item .text{
        display: table-cell;
        width: 56px;
        font-size: 12px;
        vertical-align: middle;
        text-align: center;
        border-bottom: 1px solid lightgray;
    }
    .goods .food-wrapper{
        flex: 1;
    }
</style>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值