小程序源码
This commit is contained in:
37
source/wx/xzs-student/component/iView/base/index.js
Normal file
37
source/wx/xzs-student/component/iView/base/index.js
Normal file
@@ -0,0 +1,37 @@
|
||||
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
|
||||
};
|
||||
Reference in New Issue
Block a user