微信开发者工具有个bug,真机正常
发布于 5 年前 作者 osun 13607 次浏览 来自 问答
if (typeof String.prototype.base64Encode == 'undefined') {
        String.prototype.base64Encode = function() {
            if (typeof btoa != 'undefined') return btoa(this); // browser
            if (typeof Buffer != 'undefined') return new Buffer(this, 'utf8').toString('base64'); // Node.js
            throw new Error('No Base64 Encode');
        };
    }
 
    if (typeof String.prototype.base64Decode == 'undefined') {
        String.prototype.base64Decode = function() {
            if (typeof atob != 'undefined') return atob(this); // browser
            if (typeof Buffer != 'undefined') return new Buffer(this, 'base64').toString('utf8'); // Node.js
            throw new Error('No Base64 Decode');
        };
    }

btoa 在开发者工具中未定义,但是atob居然定义了,导致加密库不能用。

2 回复

你好,真机也是不支持这个功能的

没看懂什么问题,麻烦提供一下代码片段哈(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)

回到顶部