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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

移动端瀑布流/信息流布局以及交互

發(fā)布時間:2023/12/16 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 移动端瀑布流/信息流布局以及交互 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
//瀑布流/信息流簡易布局{布局分為左右兩列排版} 1-優(yōu)點:粘貼復制代碼,小程序,H5通用,絕對滿足80%需求 2-缺點:代碼邏輯復雜用臃腫 3-分析實現(xiàn)思路:---1.布局為左右兩列布局樣式 ===left{狀態(tài)顯示兩種:--1長圖形態(tài)顯示--2短圖形態(tài)顯示}===right{1長圖形態(tài)顯示 -2短圖形態(tài)顯示}---2.數(shù)據(jù)源JSON數(shù)據(jù)List[],通過狀態(tài)區(qū)分劃分為left1[],right1[]===例如JSvar list=[{...}];后臺傳遞過來的JSON數(shù)據(jù)//聲明兩個新數(shù)組var left1=[],right1=[];//循環(huán)判斷分別追加到left1,right1數(shù)組for(var i in list){if(i%2==0){left1.push(list[i]);}if(i%2!=0){right1.push(list[i]);}}===頁面渲染中繼續(xù)使用index%2==0,index%2!=0這樣顯示區(qū)分 //如圖所示效果

? ? ? ? ? ?

//直接上代碼吧,我不是個能扯皮的人,也不啰嗦

?

<html style="font-size: 312.5%;"><head><meta content="yes" name="apple-touch-fullscreen"><meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, viewport-fit=cover"><title>購物</title><style type="text/css">html,body {padding: 0px;margin: 0 auto;background-color: #f5f5f5;}[v-cloak] {display: none !important;}.m-lookBlock {width: 3.45rem;-webkit-box-sizing: border-box;box-sizing: border-box;margin-bottom: .2rem;border-radius: .16rem;-webkit-box-align: center;-ms-flex-align: center;align-items: center;overflow: hidden;}.m-videoIconWrapper {position: absolute;top: 0;left: 0;right: 0;bottom: 0;-webkit-box-orient: horizontal;-webkit-box-direction: normal;-ms-flex-direction: row;flex-direction: row;-webkit-box-align: center;-ms-flex-align: center;align-items: center;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-pack: center;-ms-flex-pack: center;justify-content: center;}.m-videoIcon {width: .80rem;height: .80rem;}.m-lookDesc {width: 3.43rem;-webkit-box-sizing: border-box;box-sizing: border-box;padding: .18rem .16rem 0;color: #333;font-size: .28rem;line-height: .4rem;-ms-flex-direction: row;flex-direction: row;-ms-flex-wrap: wrap;flex-wrap: wrap;lines: 2;overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;font-family: 'PingFangSC-Regular';background-color: #fff;text-align: left;}.m-lookDetail {width: 3.43rem;font-size: .24rem;-webkit-box-sizing: border-box;box-sizing: border-box;padding: .17rem .16rem .24rem;-webkit-box-orient: horizontal;-webkit-box-direction: normal;-ms-flex-direction: row;flex-direction: row;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-pack: justify;-ms-flex-pack: justify;justify-content: space-between;background-color: #fff;}.u-placeHolder {width: 3.43rem;height: .17rem;background-color: #fff;}.m-lookImageWrapper {position: relative;background-color: #f2f2f2;}.m-lookImageWrapper .m-image {width: 100%;}.m-userInfo {display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-orient: horizontal;-webkit-box-direction: normal;-ms-flex-direction: row;flex-direction: row;-webkit-box-pack: right;-ms-flex-pack: right;justify-content: right;}.m-userpic {width: .48rem;height: .48rem;-webkit-box-sizing: border-box;box-sizing: border-box;border-radius: .24rem;border: 1px solid #d9d9d9;}.m-userName {overflow: hidden;text-overflow: ellipsis;white-space: nowrap;font-size: .22rem;color: #7f7f7f;height: .48rem;line-height: .48rem;margin-left: .08rem;}.m-upArea {width: 1rem;-webkit-box-orient: horizontal;-webkit-box-direction: normal;-ms-flex-direction: row;flex-direction: row;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-pack: end;-ms-flex-pack: end;justify-content: flex-end;-webkit-box-align: center;-ms-flex-align: center;align-items: center;}.m-upText {font-size: .24rem;color: #7f7f7f;max-width: .9rem;text-align: right;height: .32rem;line-height: .32rem;margin-left: .02rem;}.m-hand {width: .32rem;height: .32rem;}.m-singleGoods {width: 3.43rem;background: #FFF;font-family: 'PingFangSC-Light';-webkit-box-sizing: border-box;box-sizing: border-box;}.m-singleGoods .u-singleGoods {width: 3.05rem;border-top: .5px solid #d9d9d9;margin: 0 auto;padding-top: .2rem;padding-bottom: .2rem;}.m-singleGoods .u-singleGoods .u-goodsname {vertical-align: middle;display: inline-block;width: 2.07rem;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;font-size: .22rem;color: #333333;line-height: .32rem;height: .32rem;}.m-singleGoods .u-singleGoods .u-goBuy {/* display: inline-block;vertical-align: baseline;vertical-align: middle;width: .88rem;height: .32rem;overflow: hidden;text-align: right;position: relative;right: -.1rem; *//* display: inline-block; *//* vertical-align: baseline; *//* vertical-align: middle; *//* width: .88rem; */height: .32rem;overflow: hidden;text-align: right;position: relative;right: -.1rem;top: -0.3rem;}.m-singleGoods .u-singleGoods .u-goBuy .u-buyText {display: inline-block;vertical-align: top;font-size: .22rem;color: #DD1A21;line-height: .32rem;height: .32rem;}.m-singleGoods .u-singleGoods .u-goBuy .u-arrow {width: .1rem;height: .18rem;line-height: .32rem;margin-left: .04rem;display: inline-block;vertical-align: baseline;position: relative;top: -.04rem;}.m-collectionInfo {-webkit-box-align: center;-ms-flex-align: center;align-items: center;padding: .28rem .18rem .36rem .18rem;}.m-collectionIcon {position: absolute;left: .2rem;bottom: .2rem;width: .37rem;height: .29rem;}.m-collectionTitle {display: block;width: 3.09rem;font-size: .32rem;font-weight: bold;color: #333;line-height: .48rem;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;lines: 1;-webkit-line-clamp: 1;text-align: center;}.m-collectionLine {display: block;width: .48rem;height: .04rem;margin: 0 auto;background: #333;margin-top: .21rem;margin-bottom: .24rem;}.m-collectionText {width: 3.09rem;margin-top: .18rem;font-size: .24rem;line-height: .36rem;color: #333;-ms-flex-direction: row;flex-direction: row;-ms-flex-wrap: wrap;flex-wrap: wrap;lines: 2;overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;text-align: center;}.m-collectBgDefault {background-color: #f4f4f4;}.m-collectBg0 {background-color: #FFE1B2;}.m-collectBg1 {background-color: #FFCABE;}.m-collectBg2 {background-color: #F6D9FF;}.m-collectBg3 {background-color: #D7DEFA;}.m-collectBg4 {background-color: #C4E2FF;}.m-innerWrapper {width: 3.45rem;-webkit-box-sizing: border-box;box-sizing: border-box;border-radius: .16rem;-webkit-box-align: center;-ms-flex-align: center;align-items: center;overflow: hidden;}.m-wrapper2 {-webkit-box-align: center;-ms-flex-align: center;align-items: center;background-color: #eeeeee;}.m-lookList {width: 7.1rem;min-height: 10rem;-webkit-box-sizing: border-box;box-sizing: border-box;-webkit-box-orient: horizontal;-webkit-box-direction: normal;-ms-flex-direction: row;flex-direction: row;margin: 0 auto;margin-top: 0.3rem;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-pack: justify;-ms-flex-pack: justify;justify-content: space-between;}.m-lookColumn {width: 3.45rem;-webkit-box-align: center;-ms-flex-align: center;align-items: center;-webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column;}</style></head><body class="content"><div id="app"><div class="m-wrappers"><div class="m-lookList"><div class="m-lookColumn"><div class="m-lookBlock m-shadow" v-for="(item,index) in list1" v-if="index%2==0" v-cloak><div class="m-innerWrapper"><div><div><div class="m-lookImageWrapper" style="width: 3.45rem;"><img :src="item.img" class="m-image" style="width: 3.45rem;"><!----></div><div class="m-lookDesc">{{item.title}}</div><div class="u-placeHolder"></div><div class="m-lookDetail"><div class="m-userInfo"><img src="http://yanxuan.nosdn.127.net/ffe2a907c0bcef00f366be066f5a2a71.jpg?imageView&amp;quality=65&amp;thumbnail=48y48"class="m-userpic"><div class="m-userName">{{item.username}}</div></div><div class="m-upArea"><img src="https://img-blog.csdnimg.cn/2022010614265198484.png"class="m-hand"><div class="m-upText">{{item.num}}</div></div></div><div class="m-singleGoods"><div class="u-singleGoods"><div class="u-goodsname">{{item.content}}</div><div class="u-goBuy"><span class="u-buyText">去購買</span><img src="1"class="u-arrow"></div></div></div></div></div></div></div><!-- end --><div class="m-lookBlock m-shadow" v-for="(item,index) in list1" v-if="index%2!=0" v-cloak><div class="m-innerWrapper"><div><div><div class="m-lookImageWrapper" style="width: 3.45rem;"><img:src="item.img" class="m-image" style="width: 3.45rem;"><!----></div><div data-yxstat="{&quot;event_name&quot;:&quot;click_recognition_recommendcontent&quot;,&quot;event_action&quot;:&quot;click&quot;,&quot;page_name&quot;:&quot;recognition&quot;,&quot;parameters&quot;:{&quot;topicId&quot;:&quot;114918&quot;,&quot;extra&quot;:&quot;&quot;,&quot;type&quot;:1}}"class="m-lookDesc">{{item.title}}</div><div class="u-placeHolder"></div><div class="m-lookDetail"><div class="m-userInfo"><img :src="item.img" class="m-userpic"><div class="m-userName">選妹</div></div><div class="m-upArea"><img src="https://img-blog.csdnimg.cn/2022010614265198484.png"class="m-hand"><div class="m-upText">{{item.num}}</div></div></div><!----></div></div></div></div><!-- end --></div><div class="m-lookColumn"><div class="m-lookBlock m-shadow" v-for="(item,index) in list2" v-if="index%2==0" v-cloak><div class="m-innerWrapper"><div><div><div data-yxstat="{&quot;event_name&quot;:&quot;click_recognition_recommendcontent&quot;,&quot;event_action&quot;:&quot;click&quot;,&quot;page_name&quot;:&quot;recognition&quot;,&quot;parameters&quot;:{&quot;topicId&quot;:&quot;114976&quot;,&quot;extra&quot;:&quot;&quot;,&quot;type&quot;:1}}"class="m-lookImageWrapper" style="width: 3.45rem;"><img :src="item.img" class="m-image" style="width: 3.45rem;"><!----></div><div data-yxstat="{&quot;event_name&quot;:&quot;click_recognition_recommendcontent&quot;,&quot;event_action&quot;:&quot;click&quot;,&quot;page_name&quot;:&quot;recognition&quot;,&quot;parameters&quot;:{&quot;topicId&quot;:&quot;114976&quot;,&quot;extra&quot;:&quot;&quot;,&quot;type&quot;:1}}"class="m-lookDesc">{{item.title}}</div><div class="u-placeHolder"></div><div class="m-lookDetail"><div class="m-userInfo"><img :src="item.img" class="m-userpic"><div class="m-userName">選購指南</div></div><div class="m-upArea"><img src="https://img-blog.csdnimg.cn/2022010614265198484.png"class="m-hand"><div class="m-upText">{{item.num}}</div></div></div><!----></div></div></div></div><div class="m-lookBlock m-shadow" v-for="(item,index) in list2" v-if="index%2!=0" v-cloak><div class="m-innerWrapper"><div><div><div class="m-lookImageWrapper" style="width: 3.45rem;"><img :src="item.img" class="m-image" style="width: 3.45rem;"><!----></div><div data-yxstat="{&quot;event_name&quot;:&quot;click_recognition_recommendcontent&quot;,&quot;event_action&quot;:&quot;click&quot;,&quot;page_name&quot;:&quot;recognition&quot;,&quot;parameters&quot;:{&quot;topicId&quot;:&quot;114945&quot;,&quot;extra&quot;:&quot;&quot;,&quot;type&quot;:2}}"class="m-lookDesc">{{item.title}}</div><div class="u-placeHolder"></div><div class="m-lookDetail"><div class="m-userInfo"><img :src="item.img" class="m-userpic"><div class="m-userName">{{item.username}}</div></div><div class="m-upArea"><img src="https://img-blog.csdnimg.cn/2022010614265198484.png"class="m-hand"><div class="m-upText">{{item.num}}</div></div></div><div class="m-singleGoods"><div class="u-singleGoods"><div class="u-goodsname">{{item.content}}</div><div class="u-goBuy"><span class="u-buyText">去購買</span><img src="1"class="u-arrow"></div></div></div></div></div></div></div><!-- end --></div></div></div></div></div><!----></div><script src="./js/jquery-1.8.3.js"></script><script src="./js/vue.js"></script><script src="./js/vant.min.js"></script><!-- 根數(shù)據(jù) --><script>new Vue({el: '#app',data: {mgoodList: [{id: 1,img: "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=3347864069,1662258004&fm=26&gp=0.jpg",leaver: 1,title: "中醫(yī)小白輕松上手,無煙便攜艾灸盒",content: "簡易瀑布流布局,你們可以參考一下",price: "349",num: 10,username:"菜鳥老五",oldPrice: "789",label: ["特價", "限時優(yōu)惠"]},{id: 2,img: "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2789532059,1192373501&fm=26&gp=0.jpg",leaver: 2,title: "中醫(yī)小白輕松上手,無煙便攜艾灸盒",content: "簡易瀑布流布局,你們可以參考一下",price: "49",oldPrice: "89",username:"菜鳥老五",num: 100,label: ["新人特價"]},{id: 3,img: "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3915220323,4170882301&fm=26&gp=0.jpg",leaver: 3,title: "中醫(yī)小白輕松上手,無煙便攜艾灸盒",content: "簡易瀑布流布局,你們可以參考一下",price: "159",num: 100,username:"菜鳥老五",oldPrice: "369",label: ["折扣優(yōu)惠"]},{id: 4,img: "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=1676365759,391237942&fm=26&gp=0.jpg",leaver: 4,title: "中醫(yī)小白輕松上手,無煙便攜艾灸盒",content: "簡易瀑布流布局,你們可以參考一下",price: "29",username:"菜鳥老五",num: 100,oldPrice: "69",label: ["限時優(yōu)惠"]},{id: 5,img: "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=947016362,1269262802&fm=26&gp=0.jpg",leaver: 5,title: "中醫(yī)小白輕松上手,無煙便攜艾灸盒",content: "簡易瀑布流布局,你們可以參考一下",price: "19",num: 100,username:"菜鳥老五",oldPrice: "69",label: ["限時優(yōu)惠"]},{id: 6,img: "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2715504132,2191984566&fm=26&gp=0.jpg",leaver: 6,title: "中醫(yī)小白輕松上手,無煙便攜艾灸盒",content: "簡易瀑布流布局,你們可以參考一下",price: "349",username:"菜鳥老五",num: 100,oldPrice: "69",label: ["限時優(yōu)惠"]},{id: 7,img: "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3809412232,1951312228&fm=26&gp=0.jpg",leaver: 7,title: "中醫(yī)小白輕松上手,無煙便攜艾灸盒",content: "簡易瀑布流布局,你們可以參考一下",price: "349",username:"菜鳥老五",oldPrice: "69",num: 100,label: ["限時優(yōu)惠"]},{id: 8,img: "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=103206442,1369863903&fm=26&gp=0.jpg",leaver: 8,title: "中醫(yī)小白輕松上手,無煙便攜艾灸盒",content: "簡易瀑布流布局,你們可以參考一下",price: "349",oldPrice: "69",username:"菜鳥老五",num: 100,label: ["限時優(yōu)惠"]},{id: 9,img: "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1055672774,1388531180&fm=26&gp=0.jpg",leaver: 9,title: "中醫(yī)小白輕松上手,無煙便攜艾灸盒",content: "簡易瀑布流布局,你們可以參考一下",price: "349",num: 100,username:"菜鳥老五",oldPrice: "69",label: ["限時優(yōu)惠"]},{id: 10,img: "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=485381036,160597217&fm=26&gp=0.jpg",leaver: 10,title: "中醫(yī)小白輕松上手,無煙便攜艾灸盒",content: "簡易瀑布流布局,你們可以參考一下",price: "349",username:"菜鳥老五",num: 100,oldPrice: "69",label: ["限時優(yōu)惠"]}],list1: [],list2: []},mounted() {var that = this;that.initData();},methods: {/*** 初始化加載數(shù)據(jù)* @ param {注意} * 這里的這個mgoodList數(shù)據(jù)是后臺返回或者自定義的數(shù)據(jù)* list1左列數(shù)據(jù)* list2右列數(shù)據(jù)* 通過I%2這樣分別push近list1,list2* **/ initData() {var that = this;var mgoodList = that.mgoodList;var list1 = that.list1;var list2 = that.list2;for (var i in mgoodList) {if (i % 2 == 0) {list1.push(mgoodList[i]);}if (i % 2 != 0) {list2.push(mgoodList[i]);}}that.list1 = list1;that.list2 = list2;}}})</script></body> </html>

?

總結

以上是生活随笔為你收集整理的移动端瀑布流/信息流布局以及交互的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

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