仿饿了么商铺分类商品联动组件

组件

新建文件 zh-sliding-menu -> zh-sliding-menu.vue

<template>
	<view class="content" :style="{'height': `${scrollH}px`}">
		<view class="cont">
			<scroll-view v-if="sidebarShow" scroll-y scroll-with-animation class="cont_view menu-scroll-view" :scroll-top="scrollTop"
				:scroll-into-view="itemId" :style="[menuLeft]">
				<view v-for="(item,index) in tabbar" :key="index" class="menu_item"
					:style="[menuLeftActive,current == index?menuLeftActivea:{}]" @tap.stop="swichMenu(index)">
					<view class="menu_item_name" :style="[current == index && isTeg ? {'color':tegColor} :{}]">
						{
  {item[keyName]}}</view>
					<view class="y_teg" :style="[{'background':tegColor}]" v-if="current == index && isTeg"></view>
				</view>
			</scroll-view>
			<scroll-view :scroll-top="scrollRightTop" :scroll-y="scrollShowY" scroll-with-animation :style="[menuRight]"
				@scroll="rightScroll">
				<view class="menu_right_view">
					<view class="menu_right_item" :id="'item' + index" v-for="(item , index) in tabbar" :key="index">
						<view class="menu_right_title" v-if="item[keyName]">{
  {item[keyName]}}</view>
						<view class="">
							<slot :scroll_list='item[tabbarName]'></slot>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>
<script>
	/*
	 * zhSlidingMenu 分类商品-单向联动 + 双向联动,支持自定义商品内容
	 * @property {Array} tabbar 分类数据
	 * @property {String} keyName 从tabbar元素对象中读取的键名
	 * @property {Number} scrollH scroll高度
	 * @property {Object} menuLeft 左侧样式
	 * @property {Object} menuLeftActive 左侧未选中样式
	 * @property {Object} menuLeftActivea 左侧选中样式
	 * @property {Object} menuRight 右侧样式
	 * @property {Object} tabbarName tabbar数组中指定对象的目标属性名
	 * @property {Boolean} isTeg 左侧竖条标记
	 * @property {String} tegColor 左侧竖条标记颜色
	 * @property {Boolean} scrollY 右侧滚动到顶部开启Y轴scroll
	 * @property {Boolean} sidebarShow 是否开启侧边栏
	 * 
	 */
	export default {
     
		props: {
     
			sidebarShow:{
     
				typeof: Boolean,
				default: () => true
			},
			tabbar: {
     
				typeof: Array,
				default: () => []
			},
			keyName: {
     
				typeof: String,
				default: () => 'name'
			},
			scrollH: {
     
				typeof: Number,
				default: () => 500
			},
			menuLeft: {
     
				typeof: Object,
				default: () => ({
     
					'width': '200rpx',
					'background': '#F5F5F5',
				})
			},
			menuLeftActive: {
     
				typeof: Object,
				default: () => ({
     
					'color': '#333333',
					'font-weight': '400',
					'font-size': '30rpx',
				})
			},
			menuLeftActivea: {
     
				typeof: Object,
				default: () => ({
     
					'color': '#f82e20',
					'font-weight': '500',
					'background': '#fff',
				})
			},
			menuRight: {
     
				typeof: Object,
				default: () => ({
     
					background: '#fff',
				})
			},
			tabbarName: {
     
				typeof: String,
				default: () => 'children'
			},
			isTeg: {
     
				typeof: Boolean,
				default: () => true
			},
			tegColor: {
     
				typeof: String,
				default: () => '#f82e20'
			},
			scrollY: {
     
				typeof: Boolean,
				default: () => false
			}
		},
		data() {
     
			return {
     
				scrollTop: 0, //tab标题的滚动条位置
				oldScrollTop: 0,
				current: 0, // 预设当前项的值
				menuHeight: 0, // 左边菜单的高度
				
  • 8
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

织_网

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值