1.0.0 • Published 7 months ago

y-wx-utils v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

y-wx-utils

介绍

微信h5、小程序开发使用的相关工具方法汇总

安装教程

  npm i y-wx-utils -S

使用教程

  • 全局引入使用
// vue应用main.ts 或 taro 小程序工程 app.ts 入口文件引入注册
import Vue from 'vue';
import yWxUtils from 'y-wx-utils';
Vue.prototype.$wxUtils = yWxUtils;

// 页面组件中使用
this.$wxUtils.xxx

  • 按需局部引入使用
// 或按需引入
import {common, wxh5, wxMiniProgram} from 'y-wx-utils';

// 获取数据类型
const dataType = common.getDataType();
// 检测是否微信浏览器环境
const isWxBrowser = wxh5.checkWxBrowser();

  • 单独引入某个函数方法
import {getDataType, checkWxBrowser} from "y-wx-utils";

// 获取数据类型
const dataType = getDataType();
// 检测是否微信浏览器环境
const isWxBrowser = checkWxBrowser();

工具方法介绍

工具方法作用模块
getDataType获取数据类型common
deepClone深度克隆数据对象common
convertCodeURIParams微信小程序url传参,url参数转换common
filterHtmlStringByWhite输入框、富文本等输入的特殊字符,如标签转义过滤方法common
checkWxBrowser检测是否微信浏览器环境wxh5
getPhoneType获取手机操作系统型号wxh5
getUrlQueryParamurl中query参数转换获取wxh5
wxOaLogin微信H5公众号登录方法wxh5
getWxCode微信H5公众号发起登录后获取codewxh5
backToWxOaMenu微信公众号H5手动回退到公众号菜单窗口wxh5
disabledWxOaBackHistoryRoute禁用历史路由回退wxh5
getTaroMiniProgramElementRecttaro小程序获取元素相关位置信息wxMiniProgram