首页 > ionic 中 用request抓取数据,app程序白屏死机

ionic 中 用request抓取数据,app程序白屏死机

这段代码我单独执行过,是没有问题,可以抓取到数据的,就抓一个href和title
js代码:

    var url = 'http://www.neusoft.edu.cn/';

    request(url, function (err, res, body) {
        if (err) console.log(err);

        var top = {};
        var $ = cheerio.load(body);

        $('#news .topline a.toptitle').each(function (index, element) {
            var $element = $(element);

            top.href = $element.attr('href');
            top.title = $element.text();

        });
        $scope.top = top;
        //console.log(top);
    });

angular代码:

    <ion-item ng-repeat="item in top">
        {{item.href}}
        {{item.title}}
    </ion-item>

但是当我emulate模拟机的时候,启动的非常慢,大约5秒后,ionic的图标消失,然后就陷入白屏。。。。不知道是为什么。。。


ionic serve 

浏览器调试,肯定会报错的。前端怎么调用request


ionic emulate -s -c -l
看看logs

【热门文章】
【热门文章】