[breaking change] Notify: export default (#448)

This commit is contained in:
neverland 2018-08-21 15:24:28 +08:00 committed by GitHub
parent 26fa071512
commit e2d428d8cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 8 deletions

View File

@ -45,7 +45,7 @@ const defaultOptions = {
duration: 3000 duration: 3000
}; };
function Notify(options = {}) { export default function Notify(options = {}) {
const pages = getCurrentPages(); const pages = getCurrentPages();
const ctx = pages[pages.length - 1]; const ctx = pages[pages.length - 1];
@ -65,5 +65,3 @@ function Notify(options = {}) {
function parseParam(params = '') { function parseParam(params = '') {
return typeof params === 'object' ? params : { text: params }; return typeof params === 'object' ? params : { text: params };
} }
module.exports = Notify;

25
dist/notify/notify.js vendored Normal file
View File

@ -0,0 +1,25 @@
const defaultOptions = {
selector: '#van-notify',
duration: 3000
};
export default function Notify(options = {}) {
const pages = getCurrentPages();
const ctx = pages[pages.length - 1];
options = Object.assign({}, defaultOptions, parseParam(options));
const el = ctx.selectComponent(options.selector);
delete options.selector;
if (el) {
el.setData({
...options
});
el.show();
}
}
function parseParam(params = '') {
return typeof params === 'object' ? params : { text: params };
}

View File

@ -15,7 +15,7 @@
### 基础用法 ### 基础用法
```js ```js
const Notify = require('path/to/zanui-weapp/dist/notify/index'); import Notify from 'path/to/zanui-weapp/dist/notify/index';
Notify('通知内容') Notify('通知内容')
``` ```

View File

@ -45,7 +45,7 @@ const defaultOptions = {
duration: 3000 duration: 3000
}; };
function Notify(options = {}) { export default function Notify(options = {}) {
const pages = getCurrentPages(); const pages = getCurrentPages();
const ctx = pages[pages.length - 1]; const ctx = pages[pages.length - 1];
@ -65,5 +65,3 @@ function Notify(options = {}) {
function parseParam(params = '') { function parseParam(params = '') {
return typeof params === 'object' ? params : { text: params }; return typeof params === 'object' ? params : { text: params };
} }
module.exports = Notify;

View File

@ -14,7 +14,7 @@
#### 文字提示 #### 文字提示
```javascript ```javascript
const Toast = require('path/to/vant-weapp/dist/toast/index'); import Toast from 'path/to/vant-weapp/dist/toast/index';
Toast('我是提示文案,建议不超过十五字~'); Toast('我是提示文案,建议不超过十五字~');
``` ```