@codesmiths/mp-utils
v1.0.7
Published
Codesmiths Shanghai helper functions for WeChat Mini Programs
Downloads
3
Readme
CODESMITHS SHANGHAI WECHAT MINI PROGRAM HELPER FUNCTIONS - USER GUIDE
Functions Index
- Mini Program DOM
- Page selector
- px & rpx converter
- 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()