xzs-mysql/source/wx/xzs-student/component/iView/base/index.js
2020-09-02 08:44:41 +08:00

37 lines
781 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function getCtx (selector) {
const pages = getCurrentPages();
const ctx = pages[pages.length - 1];
const componentCtx = ctx.selectComponent(selector);
if (!componentCtx) {
console.error('无法找到对应的组件请按文档说明使用组件');
return null;
}
return componentCtx;
}
function Toast(options) {
const { selector = '#toast' } = options;
const ctx = getCtx(selector);
ctx.handleShow(options);
}
Toast.hide = function (selector = '#toast') {
const ctx = getCtx(selector);
ctx.handleHide();
};
function Message(options) {
const { selector = '#message' } = options;
const ctx = getCtx(selector);
ctx.handleShow(options);
}
module.exports = {
$Toast: Toast,
$Message: Message
};