• 壁纸小程序Vue3(分类页面和用户页面基础布局)


    1.配置tabBar

     pages.json

    1. "tabBar": {
    2. "color": "#9799a5",
    3. "selectedColor": "#28B389",
    4. "list": [
    5. {
    6. "text": "推荐",
    7. "pagePath": "pages/index/index",
    8. "iconPath": "static/images/tabBar/home.png",
    9. "selectedIconPath": "static/images/tabBar/home-h.png"
    10. },
    11. {
    12. "text": "分类",
    13. "pagePath": "pages/classify/classify",
    14. "iconPath": "static/images/tabBar/classify.png",
    15. "selectedIconPath": "static/images/tabBar/classify-h.png"
    16. },
    17. {
    18. "text": "我的",
    19. "pagePath": "pages/user/user",
    20. "iconPath": "static/images/tabBar/user.png",
    21. "selectedIconPath": "static/images/tabBar/user-h.png"
    22. }
    23. ]
    24. }

     2.分类页面

     classify.vue

     

    1. <template>
    2. <view class="classLayout">
    3. <view class="classify">
    4. <theme-item v-for="item in 15"></theme-item>
    5. </view>
    6. </view>
    7. </template>
    8. <script setup>
    9. </script>
    10. <style lang="scss" scoped>
    11. .classify{
    12. padding: 30rpx;
    13. display: grid;
    14. grid-template-columns: repeat(3,1fr);
    15. gap: 15rpx;
    16. }
    17. </style>

     

    3.我的页面 

    user.vue 

     1)基础布局

    1. <view class="userLayout">
    2. <view class="userInfo">
    3. <view class="avatar">
    4. <image src="/common/images/64.png" mode="aspectFill"></image>
    5. </view>
    6. <view class="ip">192.168.10.100</view>
    7. <view class="address">来自于:深圳</view>
    8. </view>
    9. <view class="section">
    10. <view class="list">
    11. <view class="row" v-for="item in 3">
    12. <view class="left">
    13. <uni-icons type="download-filled" size="20" color="#28b389"></uni-icons>
    14. <view class="text">我的下载</view>
    15. </view>
    16. <view class="right">
    17. <view class="text">33</view>
    18. <uni-icons type="right" size="15" color="#aaa"> </uni-icons>
    19. </view>
    20. </view>
    21. </view>
    22. </view>
    23. <view class="section">
    24. <view class="list">
    25. <view class="row" v-for="item in 2">
    26. <view class="left">
    27. <uni-icons type="download-filled" size="20" color="#28b389"></uni-icons>
    28. <view class="text">我的下载</view>
    29. </view>
    30. <view class="right">
    31. <view class="text">33</view>
    32. <uni-icons type="right" size="15" color="#aaa"> </uni-icons>
    33. </view>
    34. </view>
    35. </view>
    36. </view>
    37. </view>
    1. .userLayout{
    2. .userInfo{
    3. display: flex;
    4. align-items: center;
    5. justify-content: center;
    6. flex-direction: column;
    7. .avatar{
    8. width: 160rpx;
    9. height: 160rpx;
    10. border-radius: 50%;
    11. overflow: hidden;
    12. image{
    13. width: 100%;
    14. height: 100%;
    15. }
    16. }
    17. .ip{
    18. font-size: 44rpx;
    19. color: #333;
    20. padding: 20rpx 0 5rpx;
    21. }
    22. .address{
    23. font-size: 28rpx;
    24. color: #aaa;
    25. }
    26. }
    27. .section{
    28. width: 690rpx;
    29. margin: 50rpx auto;
    30. border: 1px solid #eee;
    31. border-radius: 10rpx;
    32. //设置阴影
    33. box-shadow: 0 0 30rpx rgba(0, 0, 0, 0.05);
    34. .list{
    35. .row{
    36. display: flex;
    37. justify-content: space-between;
    38. padding: 0 30rpx;
    39. height: 100rpx;
    40. //线
    41. border-bottom: 1px solid #eee;
    42. //去掉最后一条重复的线 &:代表在当前标签下
    43. &:last-child{border-bottom: 0;}
    44. .left{
    45. display: flex;
    46. align-items: center;
    47. .text{
    48. padding-left: 20rpx;
    49. color: #666;
    50. }
    51. }
    52. .right{
    53. display: flex;
    54. align-items: center;
    55. .text{
    56. font-size: 28rpx;
    57. color: #aaa;
    58. }
    59. }
    60. }
    61. }
    62. }
    63. }

    2)设置客服/拨打电话按钮


             
                 
                     
                        type="chatboxes-filled" size="20" color="#28b389">
                        联系客服
                     

                     
                          33
                          color="#aaa">
                     

    //条件编译
                         
                       
                       
                       
                       
                                        
                 
             
         

      //客服按钮
            button{
              position: absolute;
              top: 0;
              left: 0;
              height: 100rpx;
              width: 100%;
              opacity: 0;
            }

    4.设置全局线性渐变背景色

     user.vue

     common-style.scss

     

    view,swiper,swiper-item{
      //内填充
      box-sizing: border-box;
    }

    .pageBg{
      //线性渐变
      //从左到右
      // background: linear-gradient(to right,red,#fff,green);
      //transparent:也可以表示透明色
      background: 
      // linear-gradient(to bottom,rgba(0,0,0,0) 50%,#fff 100%),
      linear-gradient(to bottom,rgba(0,0,0,0) , #fff  400rpx),
      linear-gradient(to right,#beecd8 20%,#F4E2D8)
      ;
      min-height: 80vh;

      
    }
     

    5.自定义颜色变量

    在common下创建base-style.scss

    在官方文件uni.scss中导入:@import "@/common/style/base-style.scss";

    注:导入重启时,需要重新运行Uniapp,这样才不会报错

    $brand-theme-color:#28B389;      //品牌主体红色

    $border-color:#e0e0e0;           //边框颜色
    $border-color-light:#efefef;     //边框亮色

    $text-font-color-1:#000;         //文字主色
    $text-font-color-2:#676767;      //副标题颜色
    $text-font-color-3:#a7a7a7;      //浅色
    $text-font-color-4:#e4e4e4;      //更浅

    使用

    .date{
            color: $brand-theme-color;
       }

    //这样写在H5中可以生效,小程序中不能生效

     .uni-icons{
              //!important:代表权重最高
              color: $brand-theme-color !important;
        }

    //所以修改为如下即可:

     //穿透到组件内部,去改变组件类名
            :deep(){
              .uni-icons{
                //!important:代表权重最高
                color: $brand-theme-color !important;
              }
            }

     

  • 相关阅读:
    关系数据库系统中的 NULL 值及其用途
    菇多糖-聚乙二醇-大环配体NOTA,大环配体NOTA-PEG-香菇多糖
    面向对象
    Java List排序 java ListMap 排序 Java listmap 模拟 oracle 排序 Java listmap 模拟 mysql 排序
    Memcached&Redis构建缓存服务器
    Gem5 for Ubuntu20.04
    如何区分代理IP
    vue中省市区
    康拓123发卡软件支持PN532读卡器
    Leetcode978. Longest Turbulent Subarray
  • 原文地址:https://blog.csdn.net/jklzbc/article/details/137194150