小编Mor*_*ton的帖子

React native ERROR Packager无法侦听端口8081

当我命令时react-native start,它显示Packager can't listen on port 8081.

我知道问题是关于使用我的端口8081的一些软件.

我使用资源监视器来查看端口,但我找不到8081,没有8081,有人可以教我如何找到它吗?提前致谢. 在此输入图像描述

react-native

69
推荐指数
7
解决办法
9万
查看次数

NavigationActions.reset不是一个函数?

我创建了一个项目,Welcome屏幕导航到MainActivity屏幕.我希望当用户点击后退按钮时,它将关闭应用程序而MainActivity不是返回到Welcome屏幕.我使用该库react-navigation,所以我从Github寻找一些解决方案.

当我使用https://github.com/react-navigation/react-navigation/issues/295中的代码时.我收到错误:

NavigationActions.reset is not a function
Run Code Online (Sandbox Code Playgroud)

我console.log(NavigationActions);

在此输入图像描述

显然没有重置.但是为什么其他人都可以使用这些代码呢?

我无法弄清楚.任何帮助,将不胜感激.提前致谢.

这是我的Welcome.js:

import React, { Component } from 'react';
import { View, Text, ActivityIndicator } from 'react-native';
import { NavigationActions } from 'react-navigation';
import { connect } from 'react-redux';
import { ColorSetting } from './common/ColorSetting';
import { fetchMainMovieList } from '../actions';

class Welcome extends Component {
  static navigationOptions = {
    header: null,
  };

  componentDidMount() {
    // call main page …
Run Code Online (Sandbox Code Playgroud)

react-native react-navigation

18
推荐指数
2
解决办法
1万
查看次数

如何使用pymongo删除一个集合?

我使用MongoDB scarpy来抓取数据并将其保存到云托管中mLab.

我的收藏名称是recently,数据的数量是5. 在此输入图像描述

我想再次抓取数据并更新我的集合recently,所以我尝试删除集合然后插入.

这是我的代码pipelines.py:

from pymongo import MongoClient
from scrapy.conf import settings

class MongoDBPipeline(object):

    def __init__(self):
        connection = MongoClient(
            settings['MONGODB_SERVER'],
            settings['MONGODB_PORT'])
        db = connection[settings['MONGODB_DB']]
        # here is my collection name recently setting
        self.collection = db[settings['MONGODB_COLLECTION']]

    def process_item(self, item, spider):
        # try to drop my collection recently
        self.collection.drop()
        self.collection.insert(dict(item))
        return item
Run Code Online (Sandbox Code Playgroud)

但是当我运行我的蜘蛛时,我看到我的收集recently计数是10(它应该是5我想要的) 在此输入图像描述

我正在寻找一些如何删除集合的代码.它只是说db.[集合名称] .drop()

但是,当我尝试self.collection.drop()之前,它在我的情况下无效self.collection.insert(dict(item))

任何人都可以给我一些建议我的代码有什么问题?

那将是值得赞赏的.提前致谢.

python scrapy pymongo

11
推荐指数
1
解决办法
8630
查看次数

动态更改标签文本标题

我有一个tablayout,在viewpager下有四个标签.我想在滑动标签时更改文字标题.我的问题是我无法分别处理标签.

例如,四个标签标题是1,2,3,4,当我滑动它将显示像1,9,3,4或1,2,9,4 ...

但在我的情况下是7,9,7,7或7,7,9,7 ......

我尝试在onTabUnselected函数上编写它.显然我没有变量来控制它.

我接下来该怎么办?

该计划的一部分:

private ViewPager viewPager;

viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayoutHomePage));
        tabLayoutHomePage.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                int id=tab.getPosition();
                switch (id){
                    case 0:
                        tab.setText("9");
                        break;
                    case 1:
                        tab.setText("9");
                        break;
                    case 2:
                        tab.setText("9");
                        break;
                    case 3:
                        tab.setText("9");
                        break;
                }
                    viewPager.setCurrentItem(tab.getPosition());
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {
                int id=tab.getPosition();
                switch (id){
                    case 0:
                        tab.setText("7");
                        break;
                    case 1:
                        tab.setText("7");
                        break;
                    case 2:
                        tab.setText("7");
                        break;
                    case 3:
                        tab.setText("7");
                        break;
                }
            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            } …
Run Code Online (Sandbox Code Playgroud)

android

9
推荐指数
1
解决办法
4594
查看次数

如果高度是动态的,如何将每个项目的高度放入 getItemLayout 中?

我想用来getItemLayout<FlatList />效率更高。

但是当用于onLayout获取不稳定的列表高度时,可能是 128 或 230 或 183。

所以设置itemHeight为128进getItemLayout是不能正常工作的。

有没有其他方法可以让我itemHeight的动态高度进入我的getItemLayout

onLayout(event) {
  const {x, y, height, width} = event.nativeEvent.layout;
  console.log('height:', height); // the height is dynamic
}

renderItem = ({ item }) => {
  return (
    <View onLayout={(event) => this.onLayout(event)} style={styles.floorView} style={styles.itemView}>
      <Text>{item.name}</Text>
    </View>
  );
}

<FlatList
  data={DUMMY_LIST}
  ref={(ref) => { this.flatListRef = ref; }}
  renderItem={this.renderItem}
  numColumns={1}
  keyExtractor={(item, index) => index.toString()}
  getItemLayout={(data, index)=> {
  return { …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-flatlist react-native-sectionlist

9
推荐指数
0
解决办法
1204
查看次数

如何发送请求标题是"内容类型":"应用程序/ json"在排球时获取

我尝试在Volley上使用GET,但我需要发送请求application/json.

我看了一些答案,我尝试使用jsonBody,但它显示错误:

null com.android.volley.ServerError

这是我的代码:

public class MainActivity extends AppCompatActivity {

    String url = "http://114.35.246.42:2212/MobileApp/DEST_WebService.asmx/GetNews";
    JSONObject jsonBody;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        try {
            //I try to use this for send Header is application/json
            jsonBody = new JSONObject("{\"type\":\"example\"}");
        } catch (JSONException ex) {
            ex.printStackTrace();
        }

        RequestQueue mQueue = Volley.newRequestQueue(getApplicationContext());

        JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(url, jsonBody,
                new Response.Listener<JSONObject>() {


                    @Override
                    public void onResponse(JSONObject response) {
                        Log.d("TAG", response.toString());
                    }
                }, new Response.ErrorListener() {

            @Override
            public …
Run Code Online (Sandbox Code Playgroud)

java android android-volley

8
推荐指数
2
解决办法
3万
查看次数

如何创建指定的typescript RN版本?

我输入命令以使用 typescript 创建 React Native 项目。

npx react-native init MyApp --template react-native-template-typescript
Run Code Online (Sandbox Code Playgroud)

包.json

"react-native": "0.63.2"

我想用打字稿创建 0.62.2,所以我尝试以下命令:

npx react-native init MyApp --version 0.62.2 --template react-native-template-typescript
Run Code Online (Sandbox Code Playgroud)

包.json

"react-native": "0.63.0"

是 0.63.0 而不是 0.62.2

为什么我无法使用 typescript 创建 0.62.2 ?

typescript react-native react-typescript

8
推荐指数
2
解决办法
5097
查看次数

在 React Native 上没有调试模式的时刻格式时间将成为无效日期

时刻版本是 2.24.0

我的日期值是 2019-04-23 03:16:00 +0000 UTC

我用 moment 让它变成亚洲时间,就像:

const moment = require('moment');

const localTime = moment(date).format('YYYY/MM/DD HH:mm');

<Text>{localTime}</Text>
Run Code Online (Sandbox Code Playgroud)

本地时间将显示 2019/04/23 11:16

当我在调试模式下测试它时它工作。

但是当我关闭调试模式localTime

invalid date
Run Code Online (Sandbox Code Playgroud)

安卓和IOS都会出现这个问题。

有任何想法吗 ?

momentjs react-native

7
推荐指数
1
解决办法
1098
查看次数

每天的 YouTube 查询数变为 0

我使用我的项目和 API 大约两年并且工作正常。

但我最近收到错误。

{'error': {'errors': [{'domain': 'usageLimits', 'reason': 'dailyLimitExceeded', 'message': 'Daily Limit Exceeded. The quota will be reset at midnight Pacific Time (PT). You may monitor your quota usage and adjust limits in the API Console: https://console.developers.google.com/apis/api/youtube.googleapis.com/quotas?project=', 'extendedHelp': 'https://console.developers.google.com/apis/api/youtube.googleapis.com/quotas?project=562388912346'}], 'code': 403, 'message': 'Daily Limit Exceeded. The quota will be reset at midnight Pacific Time (PT). You may monitor your quota usage and adjust limits in the API Console: https://console.developers.google.com/apis/api/youtube.googleapis.com/quotas?project='}}
Run Code Online (Sandbox Code Playgroud)

我检查了我的谷歌控制台 api,发现每天的查询数变为 0。奇怪的是它无法编辑。

在此处输入图片说明

我正在寻找一些解决方案,但似乎有人仍然无法工作,如果我有选择的话,我不想删除我的项目服务器密钥。 Youtube API v3 显示“未配置访问”

我检查了我的电子邮件,看看是否有任何我从 YouTube …

youtube-api youtube-data-api

6
推荐指数
1
解决办法
2536
查看次数

如何在JSON.stringfy之后删除\n?

我从网站解析数据并尝试更改为json对象.

这是我的功能:

function outPutJSON() {

        for (var i = 0; i < movieTitle.length; i++) {

            var handleN = movieContent[i];
            console.log('===\n');
            console.log(handleN);

            data.movie.push({
                mpvieTitle: movieTitle[i],
                movieEnTitle: movieEnTitle[i],
                theDate: theDate[i],
                theLength: theLength[i],
                movieVersion: movieVersion[i],
                youtubeId: twoId[i],
                content: movieContent[i]
            });
        };

        return JSON.stringify(data);
    }
Run Code Online (Sandbox Code Playgroud)

console.log将打印movieContent [0],如:

在此输入图像描述

但我返回JSON.stringfy(数据); 它会变成: 在此输入图像描述

有这么多/ ni想要删除它.

我试着改变回归JSON.stringfy(data);:

var allMovieData = JSON.stringify(data);
allMovieData = allMovieData.replace(/\n/g, '');
return allMovieData;
Run Code Online (Sandbox Code Playgroud)

它不起作用,结果是一样的.

如何在我使用时删除/ n JSON.stringfy()

任何帮助,将不胜感激 .提前致谢.

javascript

5
推荐指数
2
解决办法
1万
查看次数