McrbHttpClient.empty空状态组件

列表无数据(引导添加)

实例代码:


	McrbHttpClient.empty({
		id: 'listEmpty',
		type: 'nodata',
		title: '暂无数据',
		description: '当前列表还没有任何数据,快去添加吧~',
		showAction: true,
		actionText: '去添加',
		actionCallback: function () {
			alert('可跳转页面去添加数据或者执行指定函数...')
			// 执行添加数据函数
		}
	}).render();

效果展示:

搜索无结果

实例代码:


	McrbHttpClient.empty({
		id: 'searchEmpty',
		type: 'noresult',
		title: '搜索无结果',
		description: '换个关键词试试吧',
	}).render();
	

效果展示:

无权限(引导跳转)

实例代码:


	McrbHttpClient.empty({
		id: 'permEmpty',
		type: 'nopermission',
		title: '无访问权限',
		description: '请联系管理员开通相关权限',
		minHeight: '400px',
		showLink: true,
		linkText: '点击文字链接跳转页面(当前空链接)',
		linkHref: 'javascript:void(0)'
	}).render();
	

效果展示:

网络异常/加载失败(引导重试)

实例代码:


	McrbHttpClient.empty({
		id: 'errorEmpty',
		type: 'error',
		title: '加载失败',
		description: '没有找相关数据,请稍后重试',
		showAction: true,
		actionText: '重新加载',
		actionCallback: function (e, instance) {
			// 销毁:空状态组件
			instance.destroy()
			// 重新请求数据...
			alert('销毁空状态组件,去执行重新请求数据...')
		}
	}).render();
	

效果展示:

自定义图片 (type: 'custom')

实例代码:


	McrbHttpClient.empty({
		id: 'customEmpty',
		type: 'custom',
		image: McrbHttpClient.conf.assetsapi + 'img/empty/empty-network-icon.png',
		title: '<h6 style="font-size: 16px;color: blue;">网络异常</h6>',
		description: '<span style="color: burlywood;text-decoration: underline;">检查网络,请稍后重试</span>',
		imageSize: '100px',
		bgColor: 'antiquewhite'
	}).render();
	

效果展示:

完全自定义 HTML (children)

实例代码:


	var autoEmptyHtml = document.createElement('div');
	autoEmptyHtml.innerHTML = '<h2>高度自定义的空状态</h2><p>完全自己写样式</p>';
	McrbHttpClient.empty({
	    id: 'autoEmpty',
	    children: autoEmptyHtml
	}).render();
	 

效果展示:

局部更新 (update)

实例代码:


	var emptyObj = McrbHttpClient.empty({ id: 'box', type: 'nodata' })
	emptyObj.render()
	// 用户进行了搜索操作,但没搜到结果
	setTimeout(function(){
		emptyObj.update({
		    type: 'noresult',
		    title: '没有找到匹配项',
		    description: '换个词试试看吧'
		});
	}, 5000)
	

效果展示: