uni-app

// template是放置视图部分的
<template> <view> </view> </template>
// script 放置方法、数据、功能 <script> export default { data() { return { // wh: 10, cateList: [], // 遍历数组后需要先创建数据接收 cateLevel2: [], active: 0, scrollTop: 0 }; }, onl oad() { const sysInfo = uni.getSystemInfoSync() this.hw = sysInfo.windowHeight this.getCateList() }, methods: { async getCateList() { const { data:res } = await uni.$http.get('/api/public/v1/categories') if (res.Meta.status !== 200) return uni.$showMsg() this.cateList = res.message // 为二级分类赋值 this.cateLevel2 = res.message[0].children }, activeChanged(i) { this.active = i this.cateLevel2 = this.cateList[i].children this.scrollTop = this.scrollTop === 0 ? 1:0 }, gotoGoodsList(item3){ uni.navigateto({ // 点击三级分类跳转到商品列表页面 url: '/subpkg/goods_list/goods_list?cid=' + item3.cat_id }) } } } </script>
// style放置样式 <style lang="scss"> .scroll-view-container { display: flex; .left-scroll-view { width: 120px; .left-scroll-view-item { line-height: 60px; background-color: #f7f7f7; text-align: center; font-size: 12px; // 激活项的样式 &.active { background-color: #ffffff; position: relative; // 渲染激活项左侧的红色指示边线 &::before { content: ' '; display: block; width: 3px; height: 30px; background-color: #c00000; position: absolute; left: 0; top: 50%; transform: translateY(-50%); } } } } } .cate-lv2-title{ font-size: 12px; font-weight: bold; text-align: center; padding: 15px 0; } .cate-lv3-list{ display: flex; flex-wrap: wrap; .cate-lv3-item{ width: 33.33%; margin-bottom: 10px; display: flex; flex-direction: column; align-items: center; image{ width: 60px; height: 60px; } text { font-size: 12px; } } } </style>

 

相关文章

一:display:flex布局display:flex是一种布局方式。它即可以...
1. flex设置元素垂直居中对齐在之前的一篇文章中记载过如何...
移动端开发知识点pc端软件和移动端apppc端软件是什么,有哪些...
最近挺忙的,准备考试,还有其他的事,没时间研究东西,快周...
display:flex;把容器设置为弹性盒模型(设置为弹性盒模型之后...
我在网页上运行了一个Flex应用程序,我想使用Command←组合键...