2018-09-07 13:32:00 +08:00

26 lines
531 B
JavaScript

import { isObj } from '../common/utils';
const defaultOptions = {
selector: '#van-notify',
duration: 3000
};
function parseOptions(message) {
return isObj(message) ? message : { message };
}
export default function Notify(options = {}) {
const pages = getCurrentPages();
const ctx = pages[pages.length - 1];
options = Object.assign({}, defaultOptions, parseOptions(options));
const el = ctx.selectComponent(options.selector);
delete options.selector;
if (el) {
el.setData(options);
el.show();
}
}