来自文件:
onEndReachedThreshold数字
用于调用onEndReached的像素阈值(虚拟,非物理).所以我只是想知道它意味着什么,是从顶部开始的阈值,还是从底部开始的阈值.
从一开始? - 如果我设置了onEndReachedThreshold = {10}的值,那么当我滚动到10像素或其他内容时,我的onEndReached就被调用了.
从底部? - 如果我设置onEndReachedThreshold = {listview height -10}的值,我的onEndReached会在我滚动到10像素或其他内容时立即调用.
我构建了一个react-native应用程序并使用fetch api来处理服务器请求,如果从服务器返回的json不为空,它工作正常,但如果服务器的响应为空,它会给我一个错误-“Json Parse错误” :意外的 EOF”,下面是我用于获取的代码,我尝试在调试时设置断点,以查看当从服务器返回 null 时会出现什么响应,我无法找到可以放置的内容在解析响应之前检查并查看响应是否为空,因此需要帮助
return fetch(url, //service url{
method: type, // get or post
headers: {
'Accept': 'application/json',
'Content-Type': contentType,
},
body: data //some input parameters
}).then((response) => {
return response.json();
})
.then((responseJson) => {
request.onSuccess(responseJson); // success callback
})
.catch((error) => {
request.onError(error); // error callback
console.error(error);
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试将YouTube视频嵌入到我的react-native应用程序中,它可以正常工作,但是我无法获得这些视频的全屏按钮/功能。这是我的代码
<WebView
source={{uri: "https://www.youtube.com/embed/VaC9CivyV7I?version=3&enablejsapi=1&rel=0&autoplay=1&showinfo=0&controls=1&modestbranding=0"}}
style={{height:240, width:width, justifyContent:'center', alignItems:'center', backgroundColor:'black'}}
/>
Run Code Online (Sandbox Code Playgroud)
我什至尝试将iframe用作html allowfullscren="true",但没有成功。不知道该怎么做,所以请帮忙,
编辑
经过一番搜寻更有我碰到过这样的文件的全屏支持,并提出要知道,我需要实现onShowCustomView和onHideCustomView内webView.setWebChromeClient,我掏一点在我的应用程序的文件夹node_modules,发现ReactWebViewManager.java的位置”。 ./node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java“ ,似乎可能需要添加一些自定义代码webView.setWebChromeClient,但由于我不是在本机编程中表现出色,因此无法继续进行下去
我试图在react-native应用程序中使用带有fetch的Stream api,我在jeakearchibald.com提到的一个很好的例子的帮助下实现了。代码类似于:-
fetch('https://html.spec.whatwg.org/').then(function(response) {
console.log('response::-', response)
var reader = response.body.getReader();
var bytesReceived = 0;
reader.read().then(function processResult(result) {
if (result.done) {
console.log("Fetch complete");
return;
}
bytesReceived += result.value.length;
console.log(`Received ${bytesReceived} bytes of data so far`);
return reader.read().then(processResult);
});
});
Run Code Online (Sandbox Code Playgroud)
流 API 参考是:-
但看起来react-native的fetch实现与浏览器的差别不大,并且像在web上使用Stream一样使用Stream并不容易。
对于相同的https://github.com/facebook/react-native/issues/12912,react-native上已经存在未解决的问题
在网络上,我们可以从response.body.getReader()访问Stream ,其中response只是从流url的fetch调用返回的正常结果,但在react-native中,我们无法访问body,因此可以从fetch调用的响应访问getReader 。
因此,为了克服这个问题,我尝试使用rn-fetch-blob npm package,因为它支持流,但这似乎仅支持来自区域设置文件路径,因为 readStream 函数似乎不支持传递授权和其他必要的标头,所以我尝试将 RNFetchBlob.fetch 与远程 url 和必要的标头一起使用,然后使用响应中的 readStream 方法,但总是返回当前响应没有流。
RNFetchBlob.fetch('GET', 'https://html.spec.whatwg.org/')
.progress((received, total) => {
console.log('progress', received / total);
})
.then((resp) => {
// …Run Code Online (Sandbox Code Playgroud) 在我的react-native应用程序中,我有"src"文件夹,其中包含Images文件夹和屏幕文件夹.我的屏幕文件夹有各种组件,我使用以下代码从图像中获取本地图像.
<Image source={require('src/Images/logo.png')} />
Run Code Online (Sandbox Code Playgroud)
logo.png是放置在Images文件夹中的图像,还有更多这样的图像像这样被引用.现在所有这些图像都在开发模式中很好地显示但是当我使用gradlew assemblerelease生成发布apk并在我的设备上安装apk时所有图像以这种方式引用消失在某处.不知道是什么原因所以请帮助我.我的react-native版本是0.40
react-native ×4
android ×1
fetch ×1
image ×1
javascript ×1
json ×1
listview ×1
local ×1
release ×1
stream ×1
webview ×1
youtube-api ×1