問題
在開發模式下,開啟 Remote Debug 運作良好,關閉Remote Debug或者打包運作,則報錯 “cannot find variable atob”.
解決
需要添加pollify
- 安裝buffer包
npm install --save buffer
-
添加atob pollify
根目錄建立
pollify.js
在global.Buffer = require('buffer').Buffer; if (typeof atob === 'undefined') { global.atob = function (b64Encoded) { return new Buffer(b64Encoded, 'base64').toString('binary'); }; }
第一行添加index.js
import './polyfill'; import {AppRegistry} from 'react-native'; import App from './App';