mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
[breaking change] Notify: export default (#448)
This commit is contained in:
parent
26fa071512
commit
e2d428d8cd
4
dist/notify/index.js
vendored
4
dist/notify/index.js
vendored
@ -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
25
dist/notify/notify.js
vendored
Normal 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 };
|
||||||
|
}
|
@ -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('通知内容')
|
||||||
```
|
```
|
||||||
|
@ -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;
|
|
||||||
|
@ -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('我是提示文案,建议不超过十五字~');
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user