日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

PC菜单筛选器

發(fā)布時(shí)間:2023/12/31 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PC菜单筛选器 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

?

如上圖所示,不使用UI庫(kù),手寫一個(gè)篩選器

JS代碼

'use strict'; import {createElement,useEffect,useState,Fragment,useCallback,useMemo,useRef, } from 'rax'; import View from 'rax-view'; import Text from 'rax-text'; import Picture from '@ali/rax-picture'; import './index.css';const v1 ='https://img.alicdn.com/imgextra/i4/O1CN01KmlzFh1ohkrTChKp0_!!6000000005257-2-tps-18-10.png'; const v2 ='https://img.alicdn.com/imgextra/i3/O1CN01VxAOuU1E39aJS3P7Y_!!6000000000295-2-tps-18-10.png';export default function TheFilter(props) {let liTitle = [{ name: '綜合排序', id: 1 },{ name: '銷量', id: 2 },{ name: '收藏?cái)?shù)', id: 3 },{ name: '傭金金額', id: 4 },];let ch1 = [{ name: '綜合排序', id: 11 },{ name: '新品優(yōu)先', id: 12 },];let ch2 = [{ name: '傭金金額', id: 41 },{ name: '傭金比例', id: 42 },];const { changeMenu } = props;const [list, setList] = useState(liTitle);const [child1, setChild1] = useState(ch1);const [child2, setChild2] = useState(ch2);const [cur, setCur] = useState(0);const [c1, setC1] = useState(0);const [c2, setC2] = useState(0);const changeStatus = (v, index, status) => {// 處理父類篩選if (v.id === 11 || v.id === 12) {setC1(index);}if (v.id === 41 || v.id === 42) {setC2(index);}// 點(diǎn)擊子節(jié)點(diǎn)if (status) {changeMenu(v.id);stopBubbling();// 替換頭部標(biāo)題list.forEach((k) => {if (k.id === +`${v.id}`.substring(0, 1)) {k.name = v.name;}});setList(list);} else { // 點(diǎn)擊父節(jié)點(diǎn)changeMenu(v.id);setCur(index);// 復(fù)原 頭部和子內(nèi)容setList(liTitle);setC1(0);setC2(0);// setChild1(ch1);// setChild2(ch2);}};const stopBubbling = (e) => {e = window.event || e;if (e.stopPropagation) {e.stopPropagation(); // 阻止事件 冒泡傳播} else {e.cancelBubble = true; // ie兼容}};return (<View className="mod">{list.map((item, index) => {return (<ViewclassName={`${cur == index ? 'primary' : 'side'}`}key={`tilte${index}`}onClick={() => {changeStatus(item, index);}}><TextclassName="tag"lines={1}style={{ color: cur == index ? '#396efe' : '#60646f' }}>{item.name}</Text><Viewx-if={item.id === 1 || item.id === 4}className="iconDownWrapper"><PictureclassName="iconDown"source={{uri: cur == index ? v1 : v2,}}/></View><View className="sec-group" x-if={cur === 0}>{child1.map((v, index) => {return (<ViewclassName={c1 == index ? 'sec-main' : 'sec-common'}key={index}onClick={() => {changeStatus(v, index, true);}}><TextclassName={c1 == index ? 'sec-tag1' : 'sec-tag'}lines={1}>{v.name}</Text></View>);})}</View><View className="sec-mount-mod" x-if={cur === 3}>{child2.map((v, index) => {return (<ViewclassName={c2 == index ? 'sec-main' : 'sec-common'}key={index}onClick={() => {changeStatus(v, index, true);}}><TextclassName={c2 == index ? 'sec-tag1' : 'sec-tag'}lines={1}>{v.name}</Text></View>);})}</View></View>);})}</View>); }

changeMenu會(huì)將選擇的數(shù)據(jù)返回給父組件,可根據(jù)返回的數(shù)據(jù)做具體的操作

?

CSS代碼

.mod {display: flex;flex-direction: row;align-items: center;cursor: pointer;margin-bottom: 20px;margin-left: -85px; } .primary {display: flex;flex-direction: row;justify-content: center;align-items: center;width: 106px;height: 36px;background-color: #f0f6ff;border-width: 1px;border-style: solid;/* border-top-left-radius: 3px;border-bottom-left-radius: 3px; */border-color: #396efe; }.tag {margin-right: 4px;font-family: PingFang SC;font-size: 14px;font-weight: 400;line-height: 14px;white-space: nowrap; } .iconDownWrapper {display: flex;flex-direction: row;justify-content: center;align-items: center;width: 17px;height: 17px;margin-top: -2px; } .iconDown {width: 8px;height: 4px;margin-top: 1px; } .side {display: flex;flex-direction: row;align-items: center;justify-content: center;height: 36px;background-color: #ffffff;border-width: 1px;border-style: solid;width: 106px;border-color: #d4d7e1;padding: 0 18px;color: #60646f; } .side:nth-of-type(2), .side:nth-of-type(3), .side:nth-of-type(4) {border-left-style: none !important; }.labelWrapperItem0 {display: flex;flex-direction: row;justify-content: center;align-items: flex-start;width: 59px;height: 22px;white-space: nowrap; } .label {overflow: hidden;max-width: 47px;font-family: PingFang SC;font-size: 14px;font-weight: 400;color: #60646f;text-overflow: ellipsis; } .verticalLine {width: 1px;height: 34px;margin-right: 1px;background-color: #d4d7e1; } .labelWrapperItem1 {display: flex;flex-direction: row;justify-content: center;align-items: flex-start;width: 71px;height: 22px;white-space: nowrap; } .favor {overflow: hidden;max-width: 59px;font-family: PingFang SC;font-size: 14px;font-weight: 400;color: #60646f;text-overflow: ellipsis; } .verticalLine1 {width: 1px;height: 34px;margin-right: 1px;background-color: #d4d7e1; } .group {display: flex;flex-direction: row;justify-content: center;align-items: center;width: 106px;height: 22px; } .word {margin-right: 4px;font-family: PingFang SC;font-size: 14px;font-weight: 400;line-height: 14px;color: #60646f;white-space: nowrap; } .iconDownWrapper1 {display: flex;flex-direction: row;justify-content: center;align-items: center;width: 17px;height: 17px;margin-top: -1px; } .iconDown1 {width: 8px;height: 4px;margin-top: 1px; } .sec-mod {width: 107px;height: 80px;white-space: nowrap;position: absolute;top: 36px; }.sec-mount-mod {width: 107px;height: 80px;white-space: nowrap;position: absolute;background-color: #ffffff;box-shadow: 0 3px 6px 0 rgba(51, 53, 59, 0.12);border-radius: 3px;border-width: 1px;border-style: solid;border-color: #e8ebf2;top: 36px;left: 0;/* margin-left: 317px; */margin-left: 232px;z-index: 999;opacity: 0;display: block;font-size: 13px;transition: 0.3s;-webkit-transition: 0.5s;-moz-transition: 0.5s; }.primary:hover .sec-group, .primary:hover .sec-mount-mod {opacity: 1; }.sec-group {z-index: 999;display: flex;flex-direction: column;align-items: flex-start;width: 107px;height: 80px;background-color: #ffffff;box-shadow: 0 3px 6px 0 rgba(51, 53, 59, 0.12);border-radius: 3px;border-width: 1px;border-style: solid;border-color: #e8ebf2;position: absolute;top: 36px;opacity: 0;display: block;font-size: 13px;transition: 0.3s;-webkit-transition: 0.5s;-moz-transition: 0.5s; } .sec-tag {position: relative;overflow: hidden;height: 22px;max-width: 83px;margin-top: 8px;margin-left: 11px;font-family: PingFang SC;font-size: 14px;font-weight: 400;line-height: 22px;color: #33353b;text-overflow: ellipsis; } .sec-tag1 {overflow: hidden;max-width: 83px;margin-top: 8px;height: 22px;line-height: 22px;margin-left: 11px;font-family: PingFang SC;font-size: 14px;font-weight: 400;color: #396efe;text-overflow: ellipsis; } .sec-main {position: relative;display: flex;flex-direction: row;align-items: center;width: 105px;height: 40px;/* margin-top: 8px; */margin-left: 0px;background-color: #f6f8fc;line-height: 14px;border-bottom-left-radius: 2px;border-bottom-right-radius: 2px; } .sec-common {position: relative;display: flex;flex-direction: row;align-items: center;width: 105px;height: 40px;/* margin-top: 8px; */margin-left: 0px;background-color: #fff;line-height: 14px;border-bottom-left-radius: 2px;border-bottom-right-radius: 2px; }

總結(jié)

以上是生活随笔為你收集整理的PC菜单筛选器的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 欧美在线一级视频 | 国产视频999 | 银娇在线观看 | 白嫩少妇激情无码 | 一区精品视频在线观看 | 99国产在线播放 | 男人添女人下部高潮全视频 | 久久wwww| 久久精品国产一区二区电影 | 肉体粗喘娇吟国产91 | 欧美乱大交xxxxx潮喷l头像 | 欧美第五页 | 九九视频免费看 | 美女操出白浆 | 欧美日韩久久久久 | 日韩性在线 | 欧美一区二区三区日韩 | 日本一区电影 | 天堂综合在线 | 韩国三级免费 | 蜜臀在线观看 | 国产在线视频网址 | 色超碰| 黄色成人在线观看 | 林天顾悦瑶笔趣阁 | 欧美激情 国产精品 | 99亚洲国产精品 | 亚洲成人网页 | 91九色蝌蚪91por成人 | 国产精品久久无码一三区 | 久久国产精品久久久久 | 国产一区二区99 | 你懂的网址在线观看 | 亚洲精品99久久久久中文字幕 | 无码人妻精品一区二区三区在线 | 天天操天天干视频 | 96毛片| 99热网 | 成人h动漫精品一区二区 | 操女人逼逼视频 | 欧美专区视频 | 黄色成人在线网站 | 伊人亚洲影院 | 在线三区 | 亚洲一区www | 巨乳中文字幕 | 日韩视频免费观看高清完整版在线观看 | 都市激情亚洲色图 | www.超碰97.com | 欧美一级射 | 日韩欧美亚洲国产精品字幕久久久 | 性生活av | 国产免费午夜 | 黄色国产在线播放 | 伊人一级 | 大乳巨大乳j奶hd | а√天堂中文在线资源8 | 久久精品午夜福利 | 亚洲精品一区二区三区四区 | 亚洲av首页在线 | av永久网站| 全黄一级男人和女人 | 日韩不卡高清 | 免费毛片av | 日韩在线精品视频一区二区涩爱 | 中文字幕在线观看视频网站 | 久草精品在线 | 国产激情久久 | 亚洲AV成人无码久久精品巨臀 | 91视频 - 8mav| 亚洲欧美日韩国产一区二区三区 | 国产在线一区二区视频 | 美女被变态侵犯 | 天天躁日日躁狠狠躁喷水 | 巨大乳の揉んで乳榨り奶水 | 男女性网站| 久久精品国产亚洲7777 | 草免费视频 | 国产亚洲精久久久久久无码苍井空 | 久久国产精品无码一级毛片 | 尹人成人 | 国产夫绿帽单男3p精品视频 | 在线99视频 | 体内射精一区二区 | 久久人妻少妇嫩草av | 精品人妻一区二区免费视频 | 奇米99| 亚洲av成人一区二区 | 国产精品永久久久久久久久久 | 九色视频丨porny丨丝袜 | 国产欧美综合视频 | 久久午夜夜伦鲁鲁片 | 国精产品一区二区三区 | 男女啪啪软件 | 多啪啪免费视频 | 2019亚洲男人天堂 | 蕾丝视频污 | 亚洲天堂国产精品 | 久久精品久久国产 |