加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

reactjs – 在反应原生环境中要求未知模块“加密”

发布时间:2020-12-15 20:46:17 所属栏目:百科 来源:网络整理
导读:我正在使用react-native编写一个简单的Twitter应用程序.使用 twit模块获取Twitter提要和流.下面是代码,它工作正常.但是,当包含在我的react-native应用程序中时,看到错误“需要未知模块”加密“”.依赖性似乎是myapp- twit- oauth- crypto(那是节点v0.12.2的
我正在使用react-native编写一个简单的Twitter应用程序.使用 twit模块获取Twitter提要和流.下面是代码,它工作正常.但是,当包含在我的react-native应用程序中时,看到错误“需要未知模块”加密“”.依赖性似乎是myapp-> twit-> oauth-> crypto(那是节点v0.12.2的一部分).有什么建议让这个在react-native环境中工作?
var Twit = require('twit')
var T = new Twit({
    consumer_key:'',consumer_secret:'',access_token:'',access_token_secret:''
})
var filtered_tweets=[];
var error;
var isSuccess=false;

function getTweets(searchString){
    T.get('search/tweets',{q:searchString,count:100},getResponse);
    }

function getResponse(err,data,response){
        if(err) { 
            handleGetErr(err); 
        }
        handleGetData(data.statuses);
    }

function handleGetErr(err){

    enter code here

    error = err;
    }

function handleGetData(data){
    data.map(function(tweet){
      var twit={
        twit:tweet.id,created_at:tweet.created_at,text:tweet.text,retweet_count:tweet.retweet_count,favorite_count:tweet.favorite_count
      };
      filtered_tweets.push(twit);
    });
    console.log(filtered_tweets);
    isSuccess=true;
}
getTweets("@sahaswaranamam");
module.exports = getTweets;

![附] [2]

加密模块是内置的Node模块; React Native在JavaScriptCore(在设备或模拟器上)和Chrome本身(使用Chrome调试时)运行JS,因此依赖于内置Node.js模块的模块将无法运行.有关详细信息,请参阅React Native文档的 the JavaScript Runtime section.

我不确定集成到React Native应用程序有多难,但Browserify等浏览器模块捆绑包通常具有核心Node.js模块的浏览器版本,如this one for crypto.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读