0.0.11 • Published 3 years ago
@bondli/mini-api v0.0.11
@bondli/mini-api
Install
$ npm install @bondli/mini-api --save
Usage
import { env, feedback } from '@bondli/mini-api';
const { isWeb, isMiniapp } = env;
const { showLoading, hideLoading, showSuccess, showFail, showToast, showModal, showConfirm } = feedback;
Page({
data: {},
onLoad: function (options) {
console.log(isWeb, isMiniapp);
},
doShowLoading: function () {
showLoading('数据加载中,3s后消失');
setTimeout(() => {
hideLoading();
}, 3000);
},
doShowSuccess: function () {
showSuccess('操作成功!');
},
doShowFail: function () {
showFail('操作失败了');
},
doShowToast: function () {
showToast('我是一个简单提示');
},
doShowModal: function () {
showModal('abcddddd');
},
doShowConfirm: function () {
showConfirm('ccccccsd', () => {
showSuccess('你点击了OK');
});
}
});
APIS
action-sheet
showActionSheet
拉起底部的选择项,常用于简单的单选数据场景
Params
name | type | default | describe |
---|---|---|---|
options | Object | null | null |
options.itemList | Array | null | 选择项,举例: 'A','B','C' |
options.success | Function | null | 成功回调,说明:入参:res.tapIndex,选择的项目的索引 |
options.fail | Function | null | 失败回调,说明:入参:res.errMsg,错误信息 |
Example
import { actionSheet } from '@bondli/mini-api';
const { showActionSheet } = actionSheet;
showActionSheet({
itemList: ['A', 'B', 'C'],
success (res) {
console.log(res.tapIndex)
},
fail (res) {
console.log(res.errMsg)
}
});