codecamp

Vant Weapp Empty 空状态

介绍

空状态时的占位提示。

引入

在app.json或index.json中引入组件,默认为ES6版本,ES5引入方式参见快速上手

"usingComponents": {
  "van-empty": "@vant/weapp/empty/index"
}

代码演示

基础用法

<van-empty description="描述文字" />

图片类型

Empty 组件内置了多种占位图片类型,可以在不同业务场景下使用。

<!-- 通用错误 -->
<van-empty image="error" description="描述文字" />
<!-- 网络错误 -->
<van-empty image="network" description="描述文字" />
<!-- 搜索提示 -->
<van-empty image="search" description="描述文字" />

自定义图片

需要自定义图片时,可以在 image 属性中传入任意图片 URL。

<van-empty
  class="custom-image"
  image="https://img.yzcdn.cn/vant/custom-empty-image.png"
  description="描述文字"
/>

底部内容

通过默认插槽可以在 Empty 组件的下方插入内容。

<van-empty description="描述文字">
  <van-button round type="danger" class="bottom-button">按钮</van-button>
</van-empty>

<style>
  .bottom-button {
    width: 160px;
    height: 40px;
  }
</style>

API

Props

参数 说明 类型 默认值
image 图片类型,可选值为 error network search,支持传入图片 URL string default
description 图片下方的描述文字 string -

Slots

名称 说明
- 自定义底部内容
image 自定义图标
description 自定义描述文字


实例演示

Vant Weapp Divider 分割线
Vant Weapp NoticeBar 通知栏
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

Vant Weapp 废弃

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }