更新记录

0.1.6(2026-07-31) 下载此版本

  • 修复暗黑模式下加载、失败与空图片占位文字因浅色背景与亮色文字叠加而不可见的问题
  • Web、Android、iOS 与小程序端的占位背景改为跟随 --nax-color-bg-secondary,文字跟随 --nax-color-text-secondary
  • 鸿蒙端通过 APP-HARMONY 显式解析暗色主题背景、文字与图标 token,变量不可用时回退到可读的浅色组合;默认图标尺寸保持 20px

平台兼容性

uni-app x(4.25)

Chrome Safari Android iOS 鸿蒙 微信小程序
-

其他

多语言 暗黑模式 宽屏模式
× ×

nax-image

nax-ui 图片组件(uni-app x / uvue)。

基于原生 image 封装,提供统一尺寸/圆角 API,以及加载中加载失败占位。

安装

uni_modules/nax-image

依赖:

uni_modules/nax-icon

easycom 自动生效。

推荐同时安装主题包

uni_modules/nax-ui-theme

并在 App.uvue 引入:

@import "@/uni_modules/nax-ui-theme/theme/default.css";

页面根节点加 class="nax-theme"

依赖

依赖 说明
nax-icon 图标(loading 等)
nax-ui-theme 安装时依赖运行时弱依赖(组件内 var(--nax-*, fallback),未接主题也能显示)

安装 theme 后仍需:App.uvue @import + 应用 layout/页面 一处 class="nax-theme"。详见 uni_modules/nax-ui-theme/readme.md(L0/L1/L2)。

基础用法

<nax-image
  src="https://example.com/a.jpg"
  width="120"
  height="120"
  shape="round"
></nax-image>

加载 / 失败占位

默认开启 showLoading / showError。可用插槽自定义:

<nax-image src="https://example.com/a.jpg" width="160" height="120">
  <template #loading>
    <text>加载中…</text>
  </template>
  <template #error>
    <text>图片走丢了</text>
  </template>
</nax-image>

懒加载

<nax-image
  src="https://example.com/a.jpg"
  lazy-load
  width="100%"
  height="180"
></nax-image>

Props

属性 类型 默认值 说明
src string '' 图片地址
mode string aspectFill 同原生 image mode
width string 100% 宽度;纯数字按 px
height string 200 高度;纯数字按 px
shape string square square / round / circle
lazyLoad boolean false 懒加载
fadeShow boolean true 加载完成淡入(按端支持)
webp boolean false 是否解析 webp(按端支持)
draggable boolean true 是否可拖拽(Web)
showMenuByLongpress boolean false 长按菜单(小程序)
showLoading boolean true 展示加载占位
showError boolean true 展示失败占位
loadingText string '' 加载文案
errorText string 加载失败 失败文案
customClass string '' 根节点扩展 class

Events

事件 说明
load 加载成功(透传原生事件)
error 加载失败(透传原生事件)
click 点击

Slots

插槽 说明
default 覆盖在图片上的内容
loading 自定义加载占位
error 自定义失败占位

主题

Token 用途
--nax-image-bg 容器背景
--nax-image-status-bg 占位层背景
--nax-image-radius shape=round 圆角(默认跟 --nax-radius-md / 3px,对齐 button)

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

暂无用户评论。