我有一个应用程序,我使用提取来验证用户.它在几天前工作,我没有改变任何东西.刚刚从0.27升级到0.28,没有提取不起作用.
我搜索了将近2天,我已经阅读了stackoverflow中的几乎所有问题.大多数用户试图从localhost获取内容,当他们将其更改为实际的IP地址时,他们就可以使用它.但我没有从localhost获取任何东西,也是我的代码以前工作.
这是我的代码:
fetch('http://somesite.com/app/connect', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'language':'en-US',
'Authorization': 'Bearer ' + access_token,
},
body: JSON.stringify({
uid: uid,
refresh_token: refresh_token,
token: access_token,
device: device_id,
device_name: device_name,
})
})
.then((response) => response.json())
.then((responseData) => {
console.log(JSON.stringify(responseData.body))
})
.catch((err)=> {
console.log('Some errors occured');
console.log(err);
})
.done();Run Code Online (Sandbox Code Playgroud)
我试图制作一些新项目,简单,只是使用一个简单的fetch示例来教程,它给出了同样的错误.我试图打开我的网站,我试图连接到它,通过模拟器中的浏览器,它的工作原理,但似乎通过我,应用程序无法连接到任何网站/ IP.它在chrome控制台中出现此错误:
TypeError: Network request failed
at XMLHttpRequest.xhr.onerror (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:28193:8)
at XMLHttpRequest.dispatchEvent (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:14591:15)
at XMLHttpRequest.setReadyState (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:29573:6)
at XMLHttpRequest.__didCompleteResponse (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:29431:6)
at http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:29506:52
at RCTDeviceEventEmitter.emit (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:13428:23)
at MessageQueue.__callFunction (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:11999:23)
at http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:11906:8
at guard …Run Code Online (Sandbox Code Playgroud) 据我所知,即使应用程序关闭,推送通知也可用于本机反应.是否可以使用推送通知在本机中运行后台任务?
例如,当推送通知发送到设备时,它运行一个函数来从服务器和更新数据库获取数据.
我的场景很少.其中一个场景的子场景很少.如何从一个主场景导航到其中一个子场景?
示例:
<Router createReducer={reducerCreate} getSceneStyle={getSceneStyle}>
<Scene key="root">
<Scene key="login" direction="vertical" component={Login} title="Login" hideTabBar hideNavBar />
<Scene key="tabbar" initial={show}>
<Scene key="main" tabs tabBarStyle={styles.tabBarStyle} tabBarSelectedItemStyle={styles.tabBarSelectedItemStyle} tabBarIconContainerStyle={styles.tabBarIconContainerStyle} >
<Scene key="courses" component={Courses} title="Courses" icon={IconCourses} navigationBarStyle={styles.navigationBarStyle} titleStyle={styles.titleStyle} initial />
<Scene key="register" component={Register} title="Register" icon={IconRegister} navigationBarStyle={styles.navigationBarStyle} titleStyle={styles.titleStyle} />
<Scene key="schedule" component={Schedule} title="Schedule" icon={IconSchedule} navigationBarStyle={styles.navigationBarStyle} titleStyle={styles.titleStyle} />
<Scene key="evaluation" component={Schedule} title="Evaluation" icon={IconEvaluation} navigationBarStyle={styles.navigationBarStyle} titleStyle={styles.titleStyle} />
<Scene key="profile"
component={Profile}
title="Profile"
icon={IconProfile}
navigationBarStyle={styles.navigationBarStyle}
titleStyle={styles.titleStyle}
onLeft={() => { Actions.login(); }}
leftTitle="Add Account"
onRight={() => { Actions.login({type: …Run Code Online (Sandbox Code Playgroud) javascript react-router react-native react-native-router-flux
我需要在React-native中显示一个Activity(Native android,Java).我知道有几次被问过,但没有人帮我.我没有找到任何关于如何在React-Native中调用/打开活动的教程或文档.放置活动的位置以及如何将其注册/添加到项目中.
有没有任何教程或示例代码?
我正在使用react-native-camera,当我从RN运行它时,它显示了来自rn-camera的视图,我查看了它的源代码,但它没有Activity.
如果您可以确定哪些模块的react-native正在使用活动,那么它也可以提供帮助.(显示反应原生的android活动).
有一些关于如何在现有的android项目中添加本机的文档,但是我找不到任何关于如何从android导入活动的指南.
我非常感谢你的帮助.
var a = {
1: {
687: {
name:'test1'
}
}
}
var b = {
1: {
689: {
name:'test2'
}
}
}
var c = {
...a,
...b
}
console.log(c)Run Code Online (Sandbox Code Playgroud)
我期望结果是:
{
1: {
687: {
name:'test1'
},
689: {
name:'test2'
}
}
}Run Code Online (Sandbox Code Playgroud)
但它是 :
{
1: {
689: {
name:'test2'
}
}
}Run Code Online (Sandbox Code Playgroud)
我使用传播运算符错了吗?合并两个对象的最有效方法是什么?我做了一个遍历对象中每个键的函数,它可以工作,但我认为这不是写方法。
Object.assign({},a,b) 也返回相同的结果(第一个结果,我不需要)。
我遇到了一个问题:如何动态合并两个JavaScript对象的属性?
但这并不能回答我的问题。这个答案(/sf/answers/11987951/)也不是我想要的。
提前致谢。
我有一个listview,每当用户点击一个项目时,我想用onPress做一些事情(可触摸的高亮显示).
我尝试定义函数,然后在onPress中调用它们,但它们没有工作.
首先我定义了一个这样的函数:
constructor(props) {
super(props);
this.state = {
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2,
}),
loaded: false,
};
this._dosome = this._dosome.bind(this);
}
_dosome(dd){
console.log(dd);
}
Run Code Online (Sandbox Code Playgroud)
然后 :
render(){
if (!this.state.loaded) {
return this.renderLoadingView();
}
return (
<View style={{
flex: 1
}}>
<ListView
dataSource={this.state.dataSource}
renderRow={this.renderRow}
style={styles.listView}
/>
</View>
);
}
renderRow(data) {
var header = (
<View>
<View style={styles.rowContainer}>
<View style={styles.textContainer}>
<Text style={styles.title}>{data.nid}</Text>
<Text style={styles.description} numberOfLines={0}>{data.title}</Text>
</View>
</View>
<View style={styles.separator}></View>
</View>
);
///////////
var cid = …Run Code Online (Sandbox Code Playgroud) 我有一个简单的反应原生客户端用于网站,在登录页面它提供两个选项,手动输入登录代码或使用条形码扫描仪扫描它.我已经在真实设备和模拟器中测试了应用程序很多时候它工作正常.实际上我只测试ipv4,并使用fetch登录,我认为默认情况下支持ipv6.
他们在应用程序离线时通过ipv6网络说,我无法理解离线和在IPV6网络上的意义是什么?
当应用程序离线时,我向用户显示没有连接的错误.所以我不知道它会如何崩溃.
应该添加超时来获取请求修复问题?
但由于同样的错误,应用被拒绝了3次:
表现 - 2.1
感谢您的重新提交.
当我们执行以下操作时,您的应用程序在连接到IPv6网络的运行iOS 9.3.3的iPhone上崩溃:
具体来说,点击登录仍会导致应用程序崩溃.
使用您的应用时发生这种情况:
- 离线
- 在Wi-Fi上
我们附加了详细的崩溃日志,以帮助解决此问题.
这是login.js:
'use strict';
import React, { Component } from 'react';
import {
Text,
View,
Image,
TextInput,
TouchableOpacity,
ActivityIndicatorIOS,
StyleSheet,
Dimensions,
AlertIOS,
NetInfo,
} from 'react-native';
import Camera from 'react-native-camera';
var { width, height } = Dimensions.get('window');
class Login extends Component {
constructor(props){
super(props);
this.state = {
showProgress: false,
showCamera: false,
cameraType: Camera.constants.Type.back,
barcode: true,
isConnected: false,
}
}
componentWillMount(){
NetInfo.isConnected.fetch().done((data) => {
this.setState({
isConnected: …Run Code Online (Sandbox Code Playgroud)我有一个反应原生的工作应用程序.iOS项目文件由react native制作,它基于Objective-C.我发现将Objective-C转换为Swift更加困难.所以我决定在swift 3中创建一个简单的Project,然后将React Native集成到它.我按照这里的说明进行操作:http: //facebook.github.io/react-native/docs/integration-with-existing-apps.html
我做了第一步,但是当涉及到:
Magic:RCTRootView既然你的React Native组件是通过index.ios.js创建的,你需要将该组件添加到新的或现有的ViewController中.最简单的方法是可选地创建组件的事件路径,然后将该组件添加到现有的ViewController.
我们将React Native组件与ViewController中的新本机视图绑定,该视图将实际托管它,称为RCTRootView.
是否有任何准备好的样板或任何完整的教程如何集成反应本机到swift 3项目?
更新:
根据本教程:https://gist.github.com/boopathi/27d21956fefcb5b168fe
我将我的项目更新为:AppDelegate.swift:
import UIKit
import CoreData
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// initialize the rootView to fetch JS from the dev server
let rootView = RCTRootView()
rootView.scriptURL = NSURL(string: "http://localhost:8081/index.ios.js.includeRequire.runModule.bundle")
rootView.moduleName = "OpenCampus"
// Initialize a Controller to use view as React View
let rootViewController = ViewController() …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,当用户从图库中选择图像后,他需要将其某些部分涂黑。例如,在有一些名字或签名的地方画一条黑线。
只用JS可以实现吗?或者我是否必须为 android/ios 单独制作一些本机视图并实现它以响应本机?
或者是否有任何图像选择器模块提供这样的功能?
我实际上不知道,如何命名这个问题!
我有一个反应原生的JS文件,它从服务器获取数据并将其与本地数据库进行比较.我需要这个同时运行,我怎么能实现这一目标?当应用程序启动时,应该运行,更改视图(导航到其他组件)不应该销毁它,它应该仍在运行.
有解决方案吗
javascript ×9
react-native ×9
reactjs ×5
ios ×4
react-router ×2
android ×1
fetch ×1
iphone ×1
java ×1
objective-c ×1
swift ×1