微信小程序Skyline模式自定义tab组件胶囊与原生胶囊平齐,安卓和ios均自适应

news2024/12/22 16:45:23

进入下面小程序可以体验效果

 

至于原理的话,解释起来毕竟麻烦,各位可以看源码自己分析。其实很简单,就算计算布局。很多网上公布的布局,都不能正常自适应。在下这个是完美可以的 

1、WXML 

<view class="weui-navigation-bar {{extClass}}">
  <view class="weui-navigation-bar__inner {{ios ? 'ios' : 'android'}}" style="color: {{color}}; background: {{background}}; {{displayStyle}}; {{innerPaddingRight}}; {{safeAreaTop}}">

    <!-- 左侧按钮 -->
    <view class='weui-navigation-bar__left' style="{{leftWidth}};{{marginLeft}};{{Jheight}}">
      <block wx:if="{{back || homeButton}}">
        <!-- 返回上一页 -->
        <block wx:if="{{back}}">
            <view class="weui-navigation-bar__buttons weui-navigation-bar__buttons_goback" bindtap="back">
                <image src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAMAAAAKE/YAAAAC31BMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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ze9qEPicPzfCPJ0JauSCiZU556/BZIkiRJkiRJkiRJknT9/Q9hljzTPs+vjwAAAABJRU5ErkJggg==" class="weui-navigation-bar__button weui-navigation-bar__btn_goback"></image>
            </view>
        </block>
        <view class="shu-p">
            <view class="shu"></view>
        </view>
        <!-- 返回首页 -->
        <block wx:if="{{homeButton}}">
            <view class="weui-navigation-bar__buttons weui-navigation-bar__buttons_home" bindtap="home">
                <image src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAMAAAAKE/YAAAACZFBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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XzEwcy/fXXDBzjyCpEWsCWLotj/uLrrU8dFho5jWWmedK/TTfZvmny/hcsbnWpu3wQ76RjRXWVuAJwdmbEvpxv2yrr/Mh9dsGEx72BUH0vEmCnokS0SdqPz76Q+HVVTKGbb5wo/g58Qw2+mkPJ3LgEK75gKfvFcj/FtP8TZ63F81ZXXjmIwVeX+qDryC98E2+FJR4hypHWSJ9d0q+sVZ2jPsrHusIp6AeyFuyse3gEV9ysG1jJA90dHR0dHR0/r/5D7qpgSMKkkkTAAAAAElFTkSuQmCC" class="weui-navigation-bar__button weui-navigation-bar__btn_home"></image>
            </view>
        </block>
      </block>
    </view>

    <!-- 标题 -->
    <view class='weui-navigation-bar__center'>
      <view wx:if="{{loading}}" class="weui-navigation-bar__loading" aria-role="alert">
        <view
          class="weui-loading"
          aria-role="img"
          aria-label="加载中"
        ></view>
      </view>
      <block wx:if="{{title}}">
        <text>{{title}}</text>
      </block>
      <block wx:else>
        <slot name="center"></slot>
      </block>
    </view>
    
    <!-- 右侧留空 -->
    <view class='weui-navigation-bar__right'>
      <slot name="right"></slot>
    </view>
  </view>
</view>

2、WXSS

.weui-navigation-bar {
  --weui-FG-0:rgba(0,0,0,.9);
  --height: 44px;
  --left: 16px;
}
.weui-navigation-bar .android {
  --height: 48px;
}

.weui-navigation-bar {
  overflow: hidden;
  color: var(--weui-FG-0);
  flex: none;
}

.weui-navigation-bar__inner {
  position: relative;
  top: 0;
  left: 0;
  height: calc(var(--height) + env(safe-area-inset-top));
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  padding-top: env(safe-area-inset-top);
  width: 100%;
  box-sizing: border-box;
}

.weui-navigation-bar__left {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  box-sizing: border-box;
  border-radius:50px;
  border:1rpx solid #d2d2d2;
  background:#ffffff4a;
  margin-left: 15rpx;
}

.shu-p{
    width: 50%;
    height: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 5rpx;
}

.shu{
    border: 1rpx solid #cececec7;
    width: 1%;
    height: 100%;
}

.weui-navigation-bar__btn_goback_wrapper.weui-active {
  opacity: 0.5;
}

.weui-navigation-bar__btn_goback {
  width: 55rpx;
  height: 55rpx;
}

.weui-navigation-bar__buttons_goback{
    margin-top: -5rpx;
    width: 100%;
    display: flex;
    justify-content: flex-end;
}

.weui-navigation-bar__buttons_home{
    width: 100%;
}
  
  .weui-navigation-bar__btn_home_wrapper.weui-active {
    opacity: 0.5;
  }
  
  .weui-navigation-bar__btn_home {
    width: 45rpx;
    height: 45rpx;
  }

.weui-navigation-bar__center {
  font-size: 17px;
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex: 1;
  height: 100%;
}

.weui-navigation-bar__loading {
  margin-right: 4px;
  align-items: center;
}

.weui-loading {
  font-size: 16px;
  width: 16px;
  height: 16px;
  display: block;
  background: transparent url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg width='80px' height='80px' viewBox='0 0 80 80' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Ctitle%3Eloading%3C/title%3E%3Cdefs%3E%3ClinearGradient x1='94.0869141%25' y1='0%25' x2='94.0869141%25' y2='90.559082%25' id='linearGradient-1'%3E%3Cstop stop-color='%23606060' stop-opacity='0' offset='0%25'%3E%3C/stop%3E%3Cstop stop-color='%23606060' stop-opacity='0.3' offset='100%25'%3E%3C/stop%3E%3C/linearGradient%3E%3ClinearGradient x1='100%25' y1='8.67370605%25' x2='100%25' y2='90.6286621%25' id='linearGradient-2'%3E%3Cstop stop-color='%23606060' offset='0%25'%3E%3C/stop%3E%3Cstop stop-color='%23606060' stop-opacity='0.3' offset='100%25'%3E%3C/stop%3E%3C/linearGradient%3E%3C/defs%3E%3Cg stroke='none' stroke-width='1' fill='none' fill-rule='evenodd' opacity='0.9'%3E%3Cg%3E%3Cpath d='M40,0 C62.09139,0 80,17.90861 80,40 C80,62.09139 62.09139,80 40,80 L40,73 C58.2253967,73 73,58.2253967 73,40 C73,21.7746033 58.2253967,7 40,7 L40,0 Z' fill='url(%23linearGradient-1)'%3E%3C/path%3E%3Cpath d='M40,0 L40,7 C21.7746033,7 7,21.7746033 7,40 C7,58.2253967 21.7746033,73 40,73 L40,80 C17.90861,80 0,62.09139 0,40 C0,17.90861 17.90861,0 40,0 Z' fill='url(%23linearGradient-2)'%3E%3C/path%3E%3Ccircle id='Oval' fill='%23606060' cx='40.5' cy='3.5' r='3.5'%3E%3C/circle%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A") no-repeat;
  background-size: 100%;
  margin-left: 0;
  animation: loading linear infinite 1s;
}

@keyframes loading {
  from {
    transform: rotate(0);
  }
  to {
    transform: rotate(360deg);
  }
}

 3、JS

Component({
  options: {
    multipleSlots: true // 在组件定义时的选项中启用多slot支持
  },
  /**
   * 组件的属性列表
   */
  properties: {
    extClass: {
      type: String,
      value: ''
    },
    title: {
      type: String,
      value: ''
    },
    background: {
      type: String,
      value: ''
    },
    color: {
      type: String,
      value: ''
    },
    back: {
      type: Boolean,
      value: true
    },
    loading: {
      type: Boolean,
      value: false
    },
    homeButton: {
      type: Boolean,
      value: false,
    },
    animated: {
      // 显示隐藏的时候opacity动画效果
      type: Boolean,
      value: true
    },
    show: {
      // 显示隐藏导航,隐藏的时候navigation-bar的高度占位还在
      type: Boolean,
      value: true,
      observer: '_showChange'
    },
    // back为true的时候,返回的页面深度
    delta: {
      type: Number,
      value: 1
    },
  },
  /**
   * 组件的初始数据
   */
  data: {
    displayStyle: ''
  },
  lifetimes: {
    attached() {
      const rect = wx.getMenuButtonBoundingClientRect()
      wx.getSystemInfo({
        success: (res) => {
          const isAndroid = res.platform === 'android'
          const isDevtools = res.platform === 'devtools'
          this.setData({
            ios: !isAndroid,
            innerPaddingRight: `padding-right: ${res.windowWidth - rect.left}px`,
            leftWidth: `width: ${res.windowWidth - rect.left }px`,
            marginLeft:`margin-left:${res.windowWidth - rect.right}px`,
            Jheight:`height:${(res.windowHeight-rect.top)-(res.windowHeight-rect.bottom)}px`,
            safeAreaTop: isDevtools || isAndroid ? `height: calc(var(--height) + ${rect.top-10}px); padding-top: ${rect.top-1}px` : ``,
          })
        }
      })
    },
  },
  /**
   * 组件的方法列表
   */
  methods: {
    _showChange(show) {
      const animated = this.data.animated
      let displayStyle = ''
      if (animated) {
        displayStyle = `opacity: ${
          show ? '1' : '0'
        };transition:opacity 0.5s;`
      } else {
        displayStyle = `display: ${show ? '' : 'none'}`
      }
      this.setData({
        displayStyle
      })
    },
    back() {
      const data = this.data
      if (data.delta) {
        wx.navigateBack({
          delta: data.delta
        })
      }
      this.triggerEvent('back', { delta: data.delta }, {})
    }
  },
})

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1523806.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Flask学习(四):路由转换器

默认的路由转换器&#xff1a; string &#xff08;缺省值&#xff09; 接受任何不包含斜杠的文本int接受正整数float接受正浮点数 path类似 string&#xff0c;但可以包含斜杠uuid接受 UUID 字符串 代码示例&#xff1a; app.route(/user/<username>) def show_u…

【Jetson Nano】jetson Nano安装pytorch and torchvision

Pytorch是著名的人工智能框架&#xff0c;在部署人工智能项目的时候&#xff0c;就需要在嵌入式开发板上安装pytorch&#xff0c;下面就详解介绍关于安装pytorch的步骤 1.更换apt源 首先检查apt源是否已经是国内镜像源 输入&#xff1a; sudo apt-get update如果不是国内镜像…

[Python初阶]2255.统计是给定字符串前缀的字符串数目

目录 2255.统计是给定字符串前缀的字符串数目 ①.题目 ②.问题分析 ③.startswith()方法理解 与 说明 Ⅰ.定义和用法 Ⅱ.语法 ④.问题解决 ⑤总结 2255.统计是给定字符串前缀的字符串数目 ①.题目 ②.问题分析 需求:统计列表words中,是字符串s的前缀的字符串的数目. 解…

FMR-NET:一种用于弱光图像增强的快速多尺度残差网络

这是本人发表的第二篇文章&#xff0c;目前已经见刊。欢迎大家引用。 文章链接&#xff1a;FMR-Net: a fast multi-scale residual network for low-light image enhancement | Multimedia Systems (springer.com) 代码链接&#xff1a;Github CSDN 这篇文章的特色在于&…

1、鸿蒙学习-为应用/服务进行签名

针对应用/服务的签名&#xff0c;DevEco Studio为开发者提供了自动签名方案&#xff0c;帮助开发者高效进行调试。也可选择手动方式对应用/服务进行签名&#xff0c;如果使用了需要ACL的权限&#xff0c;需采用手动方式进行签名。 自动签名 说明 使用自动签名前&#xff0c;请…

碳素光线疗法与中医

看得见的穴位碳素光线疗法 最近日本的医疗随着科学技术的发达&#xff0c;在基础研究、临床各领域取得了显著的发展。日本人的平均寿命比战前大幅延长&#xff0c;结核及其他疑难杂症、癌症等疾病也在逐渐被压制。其中&#xff0c;作为癌症的辅助疗法&#xff0c;日本癌症学会等…

【Docker】一文趣谈Docker

&#x1f3e1;浩泽学编程&#xff1a;个人主页 &#x1f525; 推荐专栏&#xff1a;《深入浅出SpringBoot》《java对AI的调用开发》 《RabbitMQ》《Spring》《SpringMVC》《项目实战》 &#x1f6f8;学无止境&#xff0c;不骄不躁&#xff0c;知行合一 文章目录 …

[MySQL]数据库基础

文章目录 1.连接服务器2.理解mysql3.初见数据库4.主流数据库5.服务器&#xff0c;数据库&#xff0c;表关系6.数据逻辑存储7.MySQL架构8.SQL分类9.存储引擎 1.连接服务器 mysql -h 127.0.0.1 -P 3306 -u root -p -h&#xff1a;指明登录部署mysql服务的主机。没有写 -h 127.0.…

Unity WebGL服务器标头的问题

目录 现象&#xff1a; 报错文本: 原因: 解决方案: 现象&#xff1a; 打包前&#xff0c;ProjectSetting 压缩选项设置为Brotli, 将打包的WebGL部署到阿里云OSS环境后&#xff0c;运行弹框提示错误. 报错文本: Unable to parse Build/WebGL.framework.js.br! This canha…

【LabVIEW FPGA入门】单周期定时循环

单周期定时循环详解 单周期定时环路是FPGA编程中最强大的结构之一。单周期定时循环中的代码更加优化&#xff0c;在FPGA上占用更少的空间&#xff0c;并且比标准While循环中的相同代码执行得更快。单周期定时环路将使能链从环路中移除&#xff0c;以节省FPGA上的空间。…

491.非递减子序列

这是一个Java程序&#xff0c;实现了一个名为Solution的类&#xff0c;该类用于查找给定整数数组中所有严格递增子序列。以下是代码的逐行注释&#xff1a; // 定义一个解决方案类 class Solution {// 初始化结果集&#xff0c;用于存储满足条件的所有严格递增子序列List<L…

第七节:Vben Admin权限-后端获取路由和菜单

系列文章目录 第一节:Vben Admin介绍和初次运行 第二节:Vben Admin 登录逻辑梳理和对接后端准备 第三节:Vben Admin登录对接后端login接口 第四节:Vben Admin登录对接后端getUserInfo接口 第五节:Vben Admin权限-前端控制方式 第六节:Vben Admin权限-后端控制方式 第七节…

nginx做静态代理方式

改配置文件 server {listen 8899;server_name localhost;location / {root html;index index.html index.htm;} } 生成页面代码 例子 GetMapping("createIndex")public Result createIndex() {//获取后台存储数据Result result productFeignClient.getB…

5G与SD-WAN的结合为企业网络注入新活力

5G作为SD-WAN的基础网络&#xff0c;具备超大带宽、超低延迟、海量连接能力&#xff0c;为企业各类业务场景提供了理想的支持&#xff0c;尤其对于对时延极为敏感的工业控制、互动应用、高带宽视频、大规模物联网应用等有着显著的推动作用。 通过与5G的融合&#xff0c;SD-WAN在…

Qt/C++监控推流设备推流/延迟极低/实时性极高/rtsp/rtmp推流/hls/flv/webrtc拉流/调整分辨率降低带宽

一、前言 算下来这个推流的项目作品写了有四年多了&#xff0c;最初第一个版本只有文件点播的功能&#xff0c;用的纯QTcpSocket通信实现&#xff0c;属于比较简单的功能。由于文件点播只支持文件形式的推流&#xff0c;不支持网络流或者本地设备采集&#xff0c;所以迫切需要…

不成功人士的7个习惯

你犹豫不决 你在做决定时犹豫不决&#xff0c;即使你辗转反侧的做了决策&#xff0c;落实到执行的时候又开始打退堂鼓&#xff0c;这种决策机制会产生一种不好的惯性&#xff0c;让你没办法做到局部最优&#xff0c;长期的随机决策让你离成功越来越远。 你缺乏清晰度 你对于…

二叉树的初步学习和顺序结构实现

当我们学完顺序表、链表、栈和队列的时候&#xff0c;我们就要开始学习树了。树对于以后的学习有非常大的帮助&#xff0c;尤其是排序。好了&#xff0c;开始我们的学习吧。 1.树的概念及结构 1.1树的结构 树结构是一种非线性结构。它是由n&#xff08;n>0&#xff09;个…

蓝桥杯每日一题——棋盘

问题描述 小蓝拥有 n xn 大小的棋盘&#xff0c;一开始棋盘上全都是白子。小蓝进行了 m 次操作&#xff0c;每次操作会将棋盘上某个范围内的所有棋子的颜色取反(也就是白色棋子变为黑色&#xff0c;黑色棋子变为白色)请输出所有操作做完后棋盘上每个棋子的颜色。输入格式 输入的…

面向对象编程第三式: 多态 (Java篇)

本篇会加入个人的所谓‘鱼式疯言’ ❤️❤️❤️鱼式疯言:❤️❤️❤️此疯言非彼疯言 而是理解过并总结出来通俗易懂的大白话, 小编会尽可能的在每个概念后插入鱼式疯言,帮助大家理解的. &#x1f92d;&#x1f92d;&#x1f92d;可能说的不是那么严谨.但小编初心是能让更多人…

2024.3.17每日一题

LeetCode 最小高度树 题目链接&#xff1a;310. 最小高度树 - 力扣&#xff08;LeetCode&#xff09; 题目描述 树是一个无向图&#xff0c;其中任何两个顶点只通过一条路径连接。 换句话说&#xff0c;一个任何没有简单环路的连通图都是一棵树。 给你一棵包含 n 个节点的…