GitXplorerGitXplorer
j

wepy-simple-toast

public
9 stars
4 forks
0 issues

Commits

List of commits on branch master.
Verified
1038e0c6ab4bd70f88cf3eaebf84731308259218

Create npm-publish.yml

jjardenliu committed 4 years ago
Unverified
d7ffa31d65491223a716e585570392c5d26fd1d6

update demo images

jjardenliu committed 6 years ago
Unverified
95e8bc01d0be697923684d64ad8482b95b2062f1

调整promise返回的参数

committed 7 years ago
Verified
949325126d9d23723a3e93b95eb582c66f77ef96

Merge pull request #1 from guobing1993/master

jjardenliu committed 7 years ago
Unverified
cb66e2c2ba4cdc3a1fa16ab1ea5e8d0ff135b29e

modify doc

committed 7 years ago
Unverified
bd678c40b04ab53161ef3bcae1c999c89db0a212

增加promise

committed 7 years ago

README

The README file for this repository.

wepy-simple-toast

微信小程序toast组件,适用于wepy,支持Promise。

使用

安装组件

  npm install wepy-simple-toast -S

引入组件

<template>
  <view class="container">
    这里是你的页面内容...
    <toast/>
  </view>
</template>

<script>
import wepy from 'wepy'
import toast from 'wepy-simple-toast'

export default class extends wepy.page {
  components = {
    toast
  }
 }
</script>

调用方法

    // 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 参数包括 successinfowarningerror
  2. options参数当前只有 duration(显示的时长)

使用进阶

使用MIXIN

  <script>
import wepy from 'wepy'
import toast from 'wepy-simple-toast'

export default class extends wepy.page {
  components = {
    toast
  }
  mixins = [toast.mixin]
 }
</script>

调用方法

    // 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

效果图

example1 example2