1.0.7 • Published 2 years ago

@codesmiths/mp-utils v1.0.7

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

CODESMITHS SHANGHAI WECHAT MINI PROGRAM HELPER FUNCTIONS - USER GUIDE

Functions Index

  1. Mini Program DOM
  2. Page selector
  3. px & rpx converter
  4. Other

Installation

Using npm:

npm i @codesmiths/mp-utils

Mini Program DOM

  • querySelect(classOrId, component)
  • getElementHeight(classOrId, component)

Examples

import cu from '@codesmiths/mp-utils'; 

cu.querySelect('#componentId', this)
  .then((res) => {
    // if found, res[0] returns wxml element
    console.log(res[0])
  })

cu.querySelect('.className', this)
  .then((res) => {
    // if found, res[0] returns array of wxml elements
    console.log(res[0])
  })

Page & Component selector

  • thisPage()
  • lastPage()
  • allPages()

Useful WeChat Component functions

// From parent component (or page) to select a child component
this.selectComponent('#componentId')

// From child component to select parent component (or page)
this.selectOwnerComponent()

px & rpx

  • getRpx(px)
  • getPx(rpx)
  • getSafeArea()
1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.2

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago