Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jardenliu/wepy-simple-toast
微信小程序toast组件,适用于wepy
https://github.com/jardenliu/wepy-simple-toast
miniapp toast wypy
Last synced: 24 days ago
JSON representation
微信小程序toast组件,适用于wepy
- Host: GitHub
- URL: https://github.com/jardenliu/wepy-simple-toast
- Owner: jardenliu
- License: mit
- Created: 2018-05-17T03:03:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-01-29T09:19:55.000Z (almost 4 years ago)
- Last Synced: 2024-12-12T13:39:18.561Z (27 days ago)
- Topics: miniapp, toast, wypy
- Language: JavaScript
- Size: 143 KB
- Stars: 9
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-wepy - wepy-simple-toast:基于wepy 的toast消息提示
README
# wepy-simple-toast
微信小程序toast组件,适用于wepy,支持Promise。## 使用
**安装组件**
```bash
npm install wepy-simple-toast -S
```
**引入组件**
```javascript
这里是你的页面内容...
import wepy from 'wepy'
import toast from 'wepy-simple-toast'export default class extends wepy.page {
components = {
toast
}
}```
**调用方法**
```javascript
// this.$invoke('toast', func, message)
this.$invoke('toast', 'success', 'simple-toast success')
//或者 this.$invoke('toast', func, message, options),当前options只有duration(显示的时长)
this.$invoke('toast', 'success', 'simple-toast success', { duration: 3000 }).then(data => {
console.log(data)
})// in async function
let data = await this.$invoke('toast', 'error', 'simple-toast error', { duration: 5000 })
console.log(data)
```
1. func 参数包括 `success`、`info`、`warning`、`error`
2. options参数当前只有 `duration`(显示的时长)## 使用进阶
**使用MIXIN**
```javascript
import wepy from 'wepy'
import toast from 'wepy-simple-toast'export default class extends wepy.page {
components = {
toast
}
mixins = [toast.mixin]
}```
**调用方法**
```javascript
// this.$infoTip(message)
this.$infoTip('simple-toast info')
//this.$errorTip(message, options)
this.$errorTip('simple-toast error', { duration: 3000 }).then(data => {
console.log(data)
})
// in async function
let data = await this.$warningTip('simple-toast warning', { duration: 3000 })
console.log(data)
```
1. mixin了四个函数 `$successTip`、`$infoTip`、`$warningTip`、`$errorTip`
2. options参数当前只有 `duration`(显示的时长)* PS: 如果`components`的名字不为`toast`,使用上述Mixin的四个函数时,需要在data里面添加`toastTagName:[toast的组件名]`
## 完整示例
点击查看 [example.wpy](https://github.com/jardenliu/wepy-simple-toast/blob/master/example.wpy)## 效果图
![example1](https://raw.githubusercontent.com/jardenliu/wepy-simple-toast/master/demo/e1.png)
![example2](https://raw.githubusercontent.com/jardenliu/wepy-simple-toast/master/demo/e2.png)