init
This commit is contained in:
28
fuintUniapp/components/toptips/toptips.js
Normal file
28
fuintUniapp/components/toptips/toptips.js
Normal file
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
function Toptips() {
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
|
||||
var pages = getCurrentPages();
|
||||
var ctx = pages[pages.length - 1];
|
||||
var defaultOptions = {
|
||||
selector: '#zan-toptips',
|
||||
duration: 3000
|
||||
};
|
||||
|
||||
options = Object.assign(defaultOptions, parseParam(options));
|
||||
|
||||
var $toptips = ctx.selectComponent(options.selector);
|
||||
delete options.selector;
|
||||
|
||||
$toptips.setData(Object.assign({}, options));
|
||||
$toptips && $toptips.show();
|
||||
}
|
||||
|
||||
function parseParam() {
|
||||
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
||||
|
||||
return typeof params === 'object' ? params : { content: params };
|
||||
}
|
||||
|
||||
module.exports = Toptips;
|
||||
Reference in New Issue
Block a user