declare var wx; let defaultConfig = { mask: true, // 是否需要蒙版 title: null, image: null, icon: 'loading', duration: 15000, // 持续时间,为0不做限制 }; // == 解析配置 function parseConfig(title, config) { if(title && typeof title === 'object'){ config = title; }else{ config = config || {}; config.title = title || config.title || defaultConfig.title; } config = (Object).assign({}, defaultConfig, config); return config; } export const loading = { init: (config) => { defaultConfig = (Object).assign({}, defaultConfig, config); }, create: (title?, config?) => { config = parseConfig(title, config); wx.showToast(config); return { close: () => { wx.hideToast() } } } }