网站搜索

javascript - React-Native-Web 的视频支持

在 React-Native-Web 中播放视频有什么解决方案吗

React-Native-Web: https://github.com/necolas/react-native-web

React-Native-Video: https://github.com/react-native-community/react-native-video

答案#1

我不知道这个解决方案有多可行,但既然你是针对网页的,你可以使用并滥用来自 react-native-web 的 createElement 来创建一个视频元素。

阅读更多 →

javascript - 有没有办法在 react-native-webview 中禁用触觉反馈

<ScrollView ref={scrollRef} horizontal scrollEnabled={isScroll} contentContainerStyle={{height: HEIGHT, overflow: 'hidden'}} style={{ width: metrics.screenWidth - widthOffset, }} onScroll={_onScroll}> <WebVi

阅读更多 →

javascript - 使用 React Native Navigation 时超出最大调用堆栈大小

我刚刚开始使用 React Native,所以我还在学习。 我正在尝试在我的应用中实现导航,几乎所有功能都正常,除了有一个页面。 在应用中,当用户注册时,他可以选择作为个人或作为组织注册,这将根据他的选择引导他进入不同的注册表单。 但是,当我选择任意一个选项时,应用会崩溃,并显示以下错误:

未捕获的错误:RangeError:已超出最大调用堆栈大小,堆栈。

我已经在网上寻找过答案,大多数情况下这是因为导航中存在无限循环。然而,我在代码中没有看到可能出现循环的地方,而且我像

阅读更多 →

javascript - 使用 react-native 为 iPad/平板启用横向模式

我正在处理一个需求,其中移动设备只支持纵向模式,而平板/iPad 支持纵向和横向模式,我不确定如何使用 react-native 实现该需求

答案#1

对于 iOS,在 ios/Info.plist 文件中包含以下几行应该就可以了:

<key>UISupportedInterfaceOrientations</key> <array> <string>UIInterfaceOrientationPort

阅读更多 →

javascript - 停止音频 expo-av - React Native Expo

我正在 react-native-expo 中使用来自 expo-av 的 Audio。

我可以使用 Audio.sound 构造函数的 loadAsync 方法来运行音频。

虽然当我尝试停止这个声音时,它并不会停止。

以下是最简化的代码片段。这是停止声音的正确方法吗?我无法找到这个问题的解决方案。

import React, {useState, useEffect} from 'react'; import { Button } from 'react-native'; import { Audio } from 'expo-av';

阅读更多 →

javascript - react-native fetch 返回奇怪的响应

我正在使用 fetch 从 API 获取一些东西,像这样:

fetch('http://facebook.github.io/react-native/movies.json') .then( data => console.log(data), error => console.log(error) )

但是我得到的是以下对象,而不是实际数据

_bodyBlob: Blob _bodyInit: Blob headers: Headers ok: true status: 200 s

阅读更多 →

javascript - 在 React Native 中通过长按连续增加计数器

我在一个 TextInput 旁边有一个按钮,按下时会增加它的计数器。

<TouchableWithoutFeedback onPress={() => {this.increaseAmount(step, rowID)}}> <View style={styles.amountPlusButtonContainer}> <Text style={styles.amountButtonText}>+</Text> </Vi

阅读更多 →

如何在 React Native 中将事件从 iOS 发送到 JavaScript

我正在在 iOS 应用中做一些异步操作。它是由 JavaScript 触发的。当它完成时(在应用的某个分离部分),我想让 JavaScript 知道。我当前的解决方案是一个继承自 RCTEventEmitter 的原生模块,它有以下方法:

@interface MyEventEmitter : RCTEventEmitter // ... end @implementation - (void)giveSomethingToJS:(NSString *)something { [self sendEventWithName:@"SOME_

阅读更多 →

javascript - 如何在 React Native iOS 项目中从 components 文件夹访问 js 文件

我无法访问 React Native 项目 iOS 中的 components 文件夹。

我收到以下错误:

无法解析模块 ./Login 来自 ....../ReactNative/ReactNativeProject/components/App.js:在其模块映射中或 ......./ReactNative/ReactNativeProject/components/Login.j 及其父目录下的任何 node_modules 目录中找不到此模块。

我参考了以下链接:http://caroaguilar.com/post/react-native-navigation-tutorial/

index.ios.js (ReactNativeProject/index.ios.js)

"use strict"; import React, { AppRegistry } from 're

阅读更多 →

javascript - React Native:如何暂时禁用 PanResponder?

下面是创建 panResponder 实例的代码片段:

constructor( props ) { super( props ); this.position = new Animated.ValueXY(); this.panResponder = PanResponder.create( { onStartShouldSetPanResponder: ( ) => true, onPanResponderMove: ( event, gesture ) => { thi

阅读更多 →