vue写一个横向滑动页面

直接上代码

<style lang="less">
page {
  background: #f0f1f2;
}
.desc {
  margin: 0 30rpx;
  height: 80rpx;
  display: inline-block;
  text-align: center;
  color: #333;
  font-family: PingFangSC-Regular;
  font-size: 28rpx;
  background: #fff;
  height: 80rpx;
  line-height: 80rpx;
}
.tab {
  height: 80rpx;
  line-height: 80rpx;
  > .tab-item {
    height: 80rpx;
    width: 50rpx;
  }
}
.active {
  display: inline-block;
  border-bottom: 4rpx solid #3d6ff0;
  color: #3d6ff0;
  cursor: pointer;
}
</style>

<template>
  <div>
  <scroll-view
    scroll-x="true"
    style=" white-space: nowrap; display: flex;background:#fff"
  >
    <div
      v-for="(item,index)  in  tabs"
      :key="index"
      class="desc"
      :class="{'active':tabIndex==index}"
      @click="click(index,item.id)"
    >{{item.name}}</div>
  </scroll-view>
</div>
</template>

<script>
import wepy from '@wepy/core';
import mixins from '../mixins/login';
import * as apis from '../utils/apis.js';

wepy.page({
  mixins: [mixins],
  data: {
    tabIndex: 1,
    tabs: [
      { name: '职位申请', id: 1 },
      { name: '预约管理', id: 2 },
      { name: '面试管理', id: 3 },
      { name: '发送offer', id: 5 },
      { name: '待入职', id: 6 },
      { name: '结束', id: 7 },
      { name: '全部', id: 0 }
    ]
  },
  methods: {
    click(index, id) {
      if (index != this.tabIndex) {
        this.tabIndex = index;
      }
    }
  },
  created() {}
});
</script>
<config>
{
    navigationBarTitleText: '51招聘云',
    enablePullDownRefresh:false,
    usingComponents: {
      init: '~@/components/init',
      icon: '~@/components/icon',
      status: '~@/components/status',
      "van-icon": "module:vant-weapp/dist/icon/index",
      "van-button": "module:vant-weapp/dist/button/index",
       "van-tab": "module:vant-weapp/dist/tab/index",
      "van-tabs": "module:vant-weapp/dist/tabs/index",

    }
}
</config>

在这里插入图片描述之前用了插件,有很多问题,后来干脆就自己手写了

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值