小编Val*_*Val的帖子

React Native Version Mismatch

在初始化新项目然后启动x-code模拟器时获取以下消息."React-Native Version Mismatch"Javascript版本0.50.1原生版本:0.50.0

确保您已重建本机代码...

有谁知道这里发生了什么,可以帮助我吗?

谢谢!

在此输入图像描述

react-native react-native-android react-native-ios

166
推荐指数
11
解决办法
9万
查看次数

重置主屏幕的导航堆栈(React Navigation和React Native)

我在React Navigation和React Native 的导航方面遇到了问题.它是关于重置导航并返回主屏幕.

我在DrawerNavigator中构建了一个StackNavigator,主屏幕和其他屏幕之间的导航工作正常.但问题是,导航堆栈的增长和增长.我不知道如何从堆栈中删除屏幕.

例如,当从主屏幕进入设置屏幕,然后进入输入屏幕并最后再次进入主屏幕时,主屏幕在堆栈中是两次.使用后退按钮我不会离开应用程序,但再次进入输入屏幕.

再次选择主页按钮时,堆栈的重置会很好,但我不知道如何执行此操作.这里有人试图帮助其他有类似问题的人,但解决方案对我不起作用.

const Stack = StackNavigator({
  Home: {
    screen: Home
  },
  Entry: {
    screen: Entry
  },
  Settings: {
    screen: Settings
  }
})

export const Drawer = DrawerNavigator({
  Home: {
    screen: Stack
  }},
  {
    contentComponent: HamburgerMenu
  }
)
Run Code Online (Sandbox Code Playgroud)

这是抽屉屏幕的一个简单示例

export default class HamburgerMenu extends Component {
  render () {
    return <ScrollView>
      <Icon.Button
        name={'home'}
        borderRadius={0}
        size={25}
        onPress={() => { this.props.navigation.navigate('Home')}}>
        <Text>{I18n.t('home')}</Text>
      </Icon.Button>

      <Icon.Button
        name={'settings'}
        borderRadius={0}
        size={25}
        onPress={() => { this.props.navigation.navigate('Settings')}}>
        <Text>{I18n.t('settings')}</Text>
      </Icon.Button>

      <Icon.Button …
Run Code Online (Sandbox Code Playgroud)

javascript navigation react-native react-navigation

40
推荐指数
6
解决办法
4万
查看次数

React Navigation back()和goBack()不起作用

我想回去两个屏幕.目标是从EditPageCover.这是我的导航堆栈:

Main -> Cover -> EditCover -> EditPage

我阅读了文档,它说要提供你想要返回的屏幕的键,这是我的代码:

this.props.navigation.dispatch(NavigationActions.back({key: 'EditCover'}));
Run Code Online (Sandbox Code Playgroud)

我也尝试过(没有运气):

this.props.navigation.dispatch(NavigationActions.back('EditCover'));
this.props.navigation.dispatch(NavigationActions.back({key: 'EditCover'}));
this.props.navigation.dispatch(NavigationActions.back({routeName: 'EditCover'}));
this.props.navigation.goBack('EditCover');
this.props.navigation.goBack({key: 'EditCover'});
this.props.navigation.goBack({routeName: 'EditCover'});
Run Code Online (Sandbox Code Playgroud)

关于这一切的有趣之处在于我没有错误.调用代码时没有任何反应......

PS如果我想回到一个屏幕,这段代码工作正常:

this.props.navigation.goBack(null);
Run Code Online (Sandbox Code Playgroud)

PSS如果在有解决方案之前有人遇到过此问题.这个黑客现在有效:

this.props.navigation.goBack(null);
this.props.navigation.goBack(null);
Run Code Online (Sandbox Code Playgroud)

react-native react-navigation

24
推荐指数
4
解决办法
4万
查看次数

随着时间的推移,Angular 4变得越来越慢

我有一个角度4.3.5应用程序,它使用一段时间后变得更慢(约20分钟).

我的情景如下:

  • 在RaspberryPi B 3上运行的Rest API和静态角度html/css/js
  • ~30 RaspberryPI B 3通过Chromium(版本58和60)访问静态角度应用

发生了什么:

  • Angular的HTTP请求在时间过后变慢.示例:从~100 ms到~2秒

附加信息:

  • 如果我在Chromium上按F5,Angular应用程序将恢复正常
  • Angular使用此模板https://themeforest.net/item/primer-angular-2-material-design-admin-template/19228165
  • Angular使用我编写的Google Chrome/Chromium应用程序,通过串口与Arduino进行通信(Chrome API:chrome.runtime.sendMessage,chrome.runtime.connect和chrome.serial)
  • 当应用程序变慢时,客户端RaspberryPi具有可用资源(CPU和内存)
  • Angular应用程序几乎不存储浏览器

提出问题的组件如下:

import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import 'rxjs/add/operator/takeUntil';
import { Subject } from 'rxjs/Subject';

import { SweetAlertService } from 'ng2-cli-sweetalert2';

import { ApiService } from '.././api.service';
import { NFCService } from '.././nfc.service';

@Component({
  selector: 'app-menu',
  templateUrl: './menu.component.html',
  styleUrls: ['./menu.component.scss']
})
export class MenuComponent implements OnInit, OnDestroy {

  private …
Run Code Online (Sandbox Code Playgroud)

google-chrome raspberry-pi angular

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

如何从htmlagility包中的节点访问子节点

<html>
    <body>
        <div class="main">
            <div class="submain"><h2></h2><p></p><ul></ul>
            </div>
            <div class="submain"><h2></h2><p></p><ul></ul>
            </div>
        </div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

我把html加载到了HtmlDocument.然后我选择了XPath作为submain.然后,我不知道如何访问到每个标签,即h2,p分别.

HtmlAgilityPack.HtmlNodeCollection nodes = doc.DocumentNode.SelectNodes("//div[@class=\"submain\"]");
foreach (HtmlAgilityPack.HtmlNode node in nodes) {}
Run Code Online (Sandbox Code Playgroud)

如果我使用node.InnerText我得到所有文本,InnerHtml也没用.如何选择单独的标签?

c# html-agility-pack

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

Vue / Typescript,得到模块 '"*.vue"' 没有导出成员

我想Component.vue文件中导出几个接口。

基本.vue:

<template>
    <div class="app">
        <router-view></router-view>
    </div>
</template>

<script lang="ts">
import { Vue, Component } from "vue-property-decorator";

export interface IBasic {
    name :string;
}

/**
 * Simplest container
 */
@Component
export class Basic extends Vue {}
export default Basic;
</script>
Run Code Online (Sandbox Code Playgroud)

但是当我从另一个.ts文件导入它时,我得到:

在此处输入图片说明

我该怎么做才能成功导入接口?

typescript vue.js vuejs2

15
推荐指数
1
解决办法
8165
查看次数

Typescript:嵌套对象的深层 keyof,具有相关类型

我正在寻找一种拥有嵌套对象的所有键/值对的方法。

(用于 MongoDB 点符号键/值类型的自动完成)

interface IPerson {
    name: string;
    age: number;
    contact: {
        address: string;
        visitDate: Date;
    }
}
Run Code Online (Sandbox Code Playgroud)

这就是我想要实现的目标,使其成为:

type TPerson = {
    name: string;
    age: number;
    contact: { address: string; visitDate: Date; }
    "contact.address": string;
    "contact.visitDate": Date;
}
Run Code Online (Sandbox Code Playgroud)

我尝试过的:

在这个答案中,我可以得到密钥Leaves<IPerson>。于是就变成了'name' | 'age' | 'contact.address' | 'contact.visitDate'

在 @jcalz 的另一个答案中,我可以通过DeepIndex<IPerson, ...>.

是否有可能将它们组合在一起,成为类似的类型TPerson

修改 9/14:用例,需要和不需要:

当我开始这个问题时,我在想它可以像这样简单[K in keyof T]: T[K];,只需进行一些巧妙的转换。但是我错了。这是我需要的:

1. 索引签名

所以界面

interface IPerson { …
Run Code Online (Sandbox Code Playgroud)

javascript mongodb mongodb-query typescript typescript-generics

15
推荐指数
2
解决办法
8990
查看次数

如何正确安装流程类型以反应native@0.46+?

我搜索了很多网站,但找不到实际适用于react-native + flow类型的教程.

来自react-native@0.22文件的流量安装指南,但它已经在react-native@0.46中消失了.

但它在运行测试和贡献中再次出现,我测试了运行npm run flow但没有工作,并且它没有说它如何使其工作.它可能是react-native文档中缺少的部分.

我需要的是使用react-native正确运行流程.每次重新加载页面时自动检查流程flow将是最好的.

flowtype react-native react-native-0.46

10
推荐指数
3
解决办法
5376
查看次数

将RxJS Observable转换为Promise

我正在尝试使用多个http调用将数据存储在本地存储中.我使用forkJoin等待所有调用完成,然后我想恢复我的Promise.then调用链.我该怎么做呢?

updateCache() {
    var cachesToUpdate;

    return this.fetchServerTimestamps()
        .then(res => {
            var localTimestamps = this.getLocalTimestamps();
            var serverTimestamps = this.getServerTimestamps();

            //Compare timestamps and decide which cache data types to update
            cachesToUpdate = this.cacheTypes.filter(function (cacheType) {
                return localTimestamps ? localTimestamps[cacheType.timestamp] != serverTimestamps[cacheType.timestamp] : true;
            });
        }).then(res => {
            //Request data and insert into cache
            this.fetchData(cachesToUpdate)
                .subscribe(res => {
                    res.forEach(function (item, index) {
                        this.insert(cachesToUpdate[index].messageType, JSON.stringify(item));
                    }.bind(this));
                });
        });
}

fetchData(cachesToUpdate): Observable<any> {
    return forkJoin(cachesToUpdate.map(i => this.callservice.serverRead({ path: 'api/' + i.messageType })));
} …
Run Code Online (Sandbox Code Playgroud)

promise observable rxjs typescript angular

8
推荐指数
1
解决办法
5063
查看次数

选项卡更改时的反应导航

如果不使用Redux,如何使用react导航选项卡导航器检测选项卡更改?

我知道我需要以某种方式使用onNavigationStateChange但我无法弄清楚如何更新当前视图.

export default () => <MyTabNav
    ref={(ref) => { this.nav = ref; }}
    onNavigationStateChange={(prevState, currentState) => {
        //call function on current view
    }}
/>;
Run Code Online (Sandbox Code Playgroud)

react-native react-navigation

8
推荐指数
4
解决办法
1万
查看次数