- Oppo Reno 3 部分蓝牙接口调用失败,是否有兼容性问题?
手机型号和系统版本: ColorOS:v7.1 Android:10 微信客户端版本:8.0.51 [图片] 可复现的代码片段: 因需要提前链接蓝牙设备,所以前面的步骤还请自行填写后测试,在下面会报错 `获取服务接口调用失败` const GetDeviceServices = (deviceId: string): Promise<WechatMiniprogram.BLEService[]> => { return new Promise((resolve, reject) => { wx.getBLEDeviceServices({ deviceId, success: (res) => { resolve(res.services) }, fail: () => { reject('获取服务接口调用失败') } }) }) }
2024-10-17 - NPM构建失败,提示文件不合法?
非常诡异呀,在我的windows主机下没有问题,换到笔记本出问题了 message:发生错误 SyntaxError: parse js file (/Users/locter/Projects/MiniApp/SmartHouseWeApp/node_modules/@npmcli/move-file/lib/index.js) failed: Unexpected token (106:14) appid: wxada906fdcb4b8b94 openid: o6zAJs7Qulzcdu7d4X8tFuzN3jc0 ideVersion: 1.06.2405020 osType: darwin-arm64 time: 2024-08-02 08:39:11 这是报错提示下的目录,我看也没有使用什么新语法 const { dirname, join, resolve, relative, isAbsolute } = require('path') const rimraf_ = require('rimraf') const { promisify } = require('util') const { access: access_, accessSync, copyFile: copyFile_, copyFileSync, readdir: readdir_, readdirSync, rename: rename_, renameSync, stat: stat_, statSync, lstat: lstat_, lstatSync, symlink: symlink_, symlinkSync, readlink: readlink_, readlinkSync, } = require('fs') const access = promisify(access_) const copyFile = promisify(copyFile_) const readdir = promisify(readdir_) const rename = promisify(rename_) const stat = promisify(stat_) const lstat = promisify(lstat_) const symlink = promisify(symlink_) const readlink = promisify(readlink_) const rimraf = promisify(rimraf_) const rimrafSync = rimraf_.sync const mkdirp = require('mkdirp') const pathExists = async path => { try { await access(path) return true } catch (er) { return er.code !== 'ENOENT' } } const pathExistsSync = path => { try { accessSync(path) return true } catch (er) { return er.code !== 'ENOENT' } } const moveFile = async (source, destination, options = {}, root = true, symlinks = []) => { if (!source || !destination) { throw new TypeError('`source` and `destination` file required') } options = { overwrite: true, ...options, } if (!options.overwrite && await pathExists(destination)) { throw new Error(`The destination file exists: ${destination}`) } await mkdirp(dirname(destination)) try { await rename(source, destination) } catch (error) { if (error.code === 'EXDEV' || error.code === 'EPERM') { const sourceStat = await lstat(source) if (sourceStat.isDirectory()) { const files = await readdir(source) await Promise.all(files.map((file) => moveFile(join(source, file), join(destination, file), options, false, symlinks) )) } else if (sourceStat.isSymbolicLink()) { symlinks.push({ source, destination }) } else { await copyFile(source, destination) } } else { throw error } } if (root) { await Promise.all(symlinks.map(async ({ source: symSource, destination: symDestination }) => { let target = await readlink(symSource) // junction symlinks in windows will be absolute paths, so we need to // make sure they point to the symlink destination if (isAbsolute(target)) { target = resolve(symDestination, relative(symSource, target)) } // try to determine what the actual file is so we can create the correct // type of symlink in windows let targetStat = 'file' try { targetStat = await stat(resolve(dirname(symSource), target)) if (targetStat.isDirectory()) { targetStat = 'junction' } } catch { // targetStat remains 'file' } await symlink( target, symDestination, targetStat ) })) await rimraf(source) } } const moveFileSync = (source, destination, options = {}, root = true, symlinks = []) => { if (!source || !destination) { throw new TypeError('`source` and `destination` file required') } options = { overwrite: true, ...options, } if (!options.overwrite && pathExistsSync(destination)) { throw new Error(`The destination file exists: ${destination}`) } mkdirp.sync(dirname(destination)) try { renameSync(source, destination) } catch (error) { if (error.code === 'EXDEV' || error.code === 'EPERM') { const sourceStat = lstatSync(source) if (sourceStat.isDirectory()) { const files = readdirSync(source) for (const file of files) { moveFileSync(join(source, file), join(destination, file), options, false, symlinks) } } else if (sourceStat.isSymbolicLink()) { symlinks.push({ source, destination }) } else { copyFileSync(source, destination) } } else { throw error } } if (root) { for (const { source: symSource, destination: symDestination } of symlinks) { let target = readlinkSync(symSource) // junction symlinks in windows will be absolute paths, so we need to // make sure they point to the symlink destination if (isAbsolute(target)) { target = resolve(symDestination, relative(symSource, target)) } // try to determine what the actual file is so we can create the correct // type of symlink in windows let targetStat = 'file' try { targetStat = statSync(resolve(dirname(symSource), target)) if (targetStat.isDirectory()) { targetStat = 'junction' } } catch { // targetStat remains 'file' } symlinkSync( target, symDestination, targetStat ) } rimrafSync(source) } } module.exports = moveFile module.exports.sync = moveFileSync
2024-08-02 - 如何在小程序Typescript模板中配置eslint?这不应该是模板配置好的东西吗?
我通过其他开发者的文章了解到原生小程序如果想用eslint就得安装跟开发者工具插件中版本一致的eslint包。我就是这么操作的,之后我又安装了小程序的ts包,通过git上的,但是报错了,如下: [图片] 下面是我目前的.eslint.js配置 /* * Eslint config file * Documentation: https://eslint.org/docs/user-guide/configuring/ * Install the Eslint extension before using this feature. */ module.exports = { env: { es6: true, browser: true, node: true, }, ecmaFeatures: { modules: true, }, parserOptions: { ecmaVersion: 2018, sourceType: 'module', }, globals: { wx: true, App: true, Page: true, getCurrentPages: true, getApp: true, Component: true, requirePlugin: true, requireMiniProgram: true, }, // extends: 'eslint:recommended', rules: { 'no-console': 0, // 设置缩进为tab 'indent': ['error', 'tab', { 'SwitchCase': 4 }], // 使用单引号 'quotes': ['error', 'single'], }, } 既然提供了ts的模板,按理说也应该提供相关的eslint配置,毕竟这可不像网页开发那样便利
2024-04-19 - wx.getSystemInfoSync() 提供假信息?
简单描述就是:wx.getSystemInfoSync()接口返回的windowHeight与真机调试返回的不符。windowHeight被注释为可使用高度,在开发者工具中减去了tabbar的高度,但真机并没有减去,导致我真机和开发者工具不一样!熬了好几天呢😁😁😁🥴 [图片] [图片] 小程序wx.getSystemInfoSync()返回虚假的windowHeight,这个问题我之前在另一个项目中也遇到过,但是当时以为是别的框架的问题,而这次换回了原生后还出现了这样的问题,我使用自定义tabbar(上次没有使用!)的时候有时候windowHeight是正常计算tabbar的但有时候又不能计算! 具体的情况在小程序开发者工具中和真机调试中出现,还有开发者版本预览。以下是代码截图 这是小程序开发者工具下的样式,计算的高度符合预期,与tabbar的灰色区域能证明,找不到看鼠标指针! [图片] 这是真机调试下的样式,最后一个元素已经超过了预期范围 [图片] 此外!在真机中减去tabbar的高度后显示的效果就是开发者工具的效果,我因为这个判断了wx.getSystemInfoSync()接口没有在真机下减去tabbar的高度 很抱歉由于工作有点忙没有办法提供demo给你们,但是!这个问题复现起来很简单。此外建议升级一下开发者社区的代码块功能,为什么是乱码的?!
2023-07-24 - Typescript 下 Component 组件对外属性的自定义类型问题,如何声明其他类型?
我有一个公共的model包,这里面存了很多共用的类型,比如用户类型、地址类型等。我还是用了一个基类,这个基类有一些公用的方法,比如时间戳转秒,金额换算等,我让其它类集成这个基类。之后在小程序的组件中传递数据的过程中发现,数据传递到组建后完全变了一个类型,我没有办法使用基类的方法。这是个很头疼的问题啊,想优雅的写个代码都是问题了。小程序都发展这么久了不应该这样呀,组件类型是很重要的事情呢。
2023-07-22 - wx.decode is not a function 几年了都还没有这个吗?
wx.decode() 和 wx.encode() 在小程序中无法使用,我看了某个朋友的帖子,2021年12月有个回答说是不支持小程序,但现在应该支持了吧?TextDecoder又用不了,我只是想把我存进去的文件再取出来,在小程序里面真难啊,哈哈
2023-03-20 - 小程序怎么获取数据分析后台的内容?
事情是这样的,我做的一个充电桩小程序,客户二期提了一个后台的需求,但因产品特性无需做网页后台,于是我就做了一个小程序版本的后台管理,在后台里面可以看到小程序的用户活跃等数据分析功能,想到小程序自带的后台也有这个功能,是否可以直接使用API拿到小程序后台的数据呀?
2022-12-03 - 如何解决Canvas层级问题?
怎么解决Canvas的层级问题?我这个百分比的组件可以根据页面上下移动的,后期也要做好多这种,你让我弹出来之后关掉Canvas不好吧?因为下面的Bar是没法关掉的,cover-view又没办法显示icon,这太离谱了 [图片]
2022-09-14 - 云开发 云函数本地调试
在使用云开发的过程中,进行了云函数的本地调试。 在输出框中总是报黄警告。并不影响云函数的运行和云函数的输出结果。 [图片] 虽然不影响结果,但是每次这样会看起来很繁杂。
2022-01-31