Coder Social home page Coder Social logo

mp-toast-component's Introduction

mp-toast-component

微信小程序自定义toast组件,提供比原生更好都表现。

功能

  1. 简便的api调用方法(Toast.showLoading('msg...')、showSuccess()、showError()、showInfo())
  2. 提供背景遮罩属性
  3. 将loading和常用提示(success、error、warn、info)集合到同一个对象中

用法

  1. 在页面的.json文件中添加组件
"usingComponents": {
"toast": "mp-toast-component"
}
  1. 在页面的.wxml文件中添加组件,并指定id(#必须#)
<!-- 页面.wxml -->
<toast id="we-toast"/>
  1. 在页面的.js文件中,导入上面的对象
<!-- 页面.js -->
import {
Toast,
} from 'mp-toast-component';
  1. 在代码中调用对象相应的方法
loading: function () {
Toast.showLoading('loading...');
},
success: function () {
Toast.showSuccess('success');
},
info: function () {
Toast.showInfo('this is a message');
},
warn: function () {
Toast.showWarn('warning warning');
},

error: function () {
Toast.showError("error: don't touch that button");
},
hide: function () {
Toast.hide();
},

mp-toast-component's People

Stargazers

 avatar  avatar opu avatar

Watchers

opu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.