Skip to content

GlobalLoading 全局加载

用于页面整体或局部容器加载时的过渡显示。

引入

组件位置

/pages/component/globalLoading/index

app.jsonindex.json 中引入组件:

json
"usingComponents": {
  "globalLoading": "/pages/component/globalLoading/index"
}

代码演示

基础用法

直接在页面中放置该组件,通过 wx:if 控制显示隐藏。

html
<globalLoading wx:if="{{ isLoading }}"></globalLoading>

局部容器加载

如果需要局部容器加载,可以为父级容器设置 position: relative (注意:由于组件默认 CSS 为 fixed,如需真正局部显示,可能需要覆盖组件样式或调整组件实现)。

html
<view style="height: 200rpx; position: relative;">
    <globalLoading></globalLoading>
</view>

API

Props

参数说明类型默认值
-该组件目前没有特定的 Props--

样式自定义

该组件使用了 van-loading,颜色固定为 #209A56 (唐管家主题绿)。背景色为纯白色。 组件外层类名为 .loading-container,默认使用 position: fixed 覆盖全屏。