实现代码// 位置变化监听 // 文档地址 https://www.html5plus.org/doc/zh_cn/geolocation.html# plus.geolocation.watchPosition( position => { //console.log('plus.geolocation.watchPosition position', position); // todo 缓存定位或者上传定位 uni.setStorageSync('watchPosition', position) // 108.307424,22.799393 var point = new plus.maps.Point(position.coords.longitude, position.coords.latitude); ts.autoUploadPoint({lng:position.coords.longitude,lat:position.coords.latitude}) plus.maps.Map.reverseGe
前言APP在不同网络下,由于网络延迟的问题会使得用户无法请求导致心情不愉快,所以咱们得做个网络不好的提示。实现// 网络状态监听 uni.onNetworkStatusChange(function (res) { console.log('onNetworkStatusChange', res.isConnected, res.networkType); if(!res.isConnected) { uni.showToast({ title: "无网络连接!", icon: "error", duration: 3500 }); } let message = null; switch(res.networkType) { case '2g': case '3g': message = '当前网络质量不佳!';
简介JavaScript implementations of standard and secure cryptographic algorithmsCryptoJS is a growing collection of standard and secure cryptographic algorithms implemented in JavaScript using best practices and patterns. They are fast, and they have a consistent and simple interface.标准和安全加密算法的 JavaScript 实现CryptoJS 是使用最佳实践和模式在 JavaScript 中实现的标准和安全加密算法的不断增长的集合。 它们速度很快,并且具有一致且简单的界面。文档CryptoJS Gitbook实现代码 import crypto from 'crypto'; import config from '~/config'; // Defining key const key = crypto.r
需求obj1={ a:'asd', b:'aassd', c:'assdfd', d:'asfdgd' } obj2={ a:'', c:'' }结果obj2={ a:'asd', c':assdfd' }实现Object.keys(obj2).map(function(key){ obj1[key] && (obj2[key] = obj1[key]); })
引入Axiosnpm - npm install axios -Syarn - yarn add axios -S编写request.js 实现axios实例/** * axios实例 */ import axios from 'axios'; import type { AxiosResponse } from 'axios'; // 定义一个响应interface,建议放置公共声明文件 interface ApiResult<T> { // 状态码 code: number; // 状态信息 message?: string; // 返回数据 data?: T; } const service = axios.create({ baseURL: import.meta.env.VITE_API_URL as string // 取得env配置的基础路径 }); // 添加请求拦截器 service.interceptors.request.use( (config) => { // todo 前置实现,比例前置追加
lettered
生,亦我所欲也;义,亦我所欲也。