Git Product home page Git Product logo

mina-page-patch's Introduction

mina-page-patch

微信小程序 Page 叠加包,让 wxml 可以直接使用 wx 下的 api,并通过 data-* 传递参数

使用

下载 page-patch.js 到小程序项目目录,在 app.js 顶部调用

import pagePatch from './page-patch.js';
pagePatch();

pagePatch 默认叠加了大部分不需要用户授权的 api,如果需要叠加更多的 api,可以传入一个数组

pagePatch(['vibrateShort']);

接下来就可以在 wxml 中直接使用 wx 下的 api,不需要在页面 js 文件中声明处理函数,例如实现点击图片进入预览

index.wxml

<image src="{{img_url}}" bindtap="$wx.previewImage" data-urls="{{[img_url]}}" />

需要用到 success, fail, complete 回调?

index.js

Page({
  previewSuccess(res) {
    console.log('previewImage success', res);
  }
});

index.wxml

<image src="{{img_url}}" bindtap="$wx.previewImage" data-urls="{{[img_url]}}" data-success="previewSuccess" />

需要驼峰参数名?

index.wxml

<button bindtap="$wx.makePhoneCall" data-phone-number="13800138000">打电话</button>

注意

  • pagePatch 必须在 app.js 顶部调用,确保页面初始化之前成功叠加

mina-page-patch's People

Contributors

littlee avatar

Watchers

 avatar  avatar

Forkers

w88quan

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.