npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

safe-area-adapter-vue2

v1.0.0

Published

Vue 2 组件,用于处理移动设备底部安全区域适配

Readme

safe-area-adapter-vue2

Vue 2 组件,用于处理移动设备底部安全区域适配。

特点

  • 自动适配移动设备底部安全区域
  • 支持自定义安全区域高度
  • 支持全局注册和组件内引入两种使用方式

安装

npm install safe-area-adapter-vue2

使用方法

全局注册

在你的入口文件(通常是 main.js)中:

import Vue from 'vue';
import SafeAreaAdapter from 'safe-area-adapter-vue2';
import 'safe-area-adapter-vue2/index.css'; // 导入样式

Vue.use(SafeAreaAdapter);

组件内引入

import { SafeAreaAdapter } from 'safe-area-adapter-vue2';
import 'safe-area-adapter-vue2/index.css'; // 导入样式

export default {
  components: {
    SafeAreaAdapter
  }
};

基本用法

<template>
  <div class="container">
    <div class="content">
      <!-- 你的页面内容 -->
    </div>

    <SafeAreaAdapter>
      <div class="footer">
        <!-- 底部区域,会自动添加安全区域适配 -->
      </div>
    </SafeAreaAdapter>
  </div>
</template>

属性

| 属性名 | 类型 | 默认值 | 描述 | | -------------- | ------------- | ------ | -------------------------------- | | safeAreaHeight | Number/String | null | 自定义安全区域高度(像素) | | enabled | Boolean | true | 是否启用安全区域适配 | | defaultHeight | Number/String | 25 | 默认安全区域高度(像素) | | fixPositionedChildren | Boolean | true | 是否自动修复父元素内的定位元素 | | createOverlay | Boolean | true | 是否添加遮罩层 | | overlayZIndex | Number/String | 9999 | 遮罩层的z-index | | overlayBackground | String | '#000' | 遮罩层背景色 |

安全区域高度获取优先级

组件会按照以下优先级获取安全区域高度:

  1. 组件属性 safeAreaHeight
  2. UserAgent 中的 bheight 参数
  3. URL 参数中的 safeAreaHeight
  4. iOS 设备上的 CSS 环境变量 env(safe-area-inset-bottom)
  5. 默认高度 defaultHeight

注意事项

  • 该组件仅支持 Vue 2.x 版本
  • 组件会自动处理横竖屏切换时的安全区域高度变化

特殊情况

当 URL 参数中 hideBottom=1 时,不会添加安全区域适配。

示例

使用内边距(默认)

<SafeAreaAdapter>
  <div class="footer">底部内容</div>
</SafeAreaAdapter>

使用外边距

<SafeAreaAdapter :usePadding="false">
  <div class="footer">底部内容</div>
</SafeAreaAdapter>

自定义安全区域高度

<SafeAreaAdapter :safeAreaHeight="40">
  <div class="footer">底部内容</div>
</SafeAreaAdapter>

禁用安全区域适配

<SafeAreaAdapter :enabled="false">
  <div class="footer">底部内容</div>
</SafeAreaAdapter>

开发

# 安装依赖
npm install

# 运行示例
npm run dev

# 构建库
npm run build

许可

MIT