react-native - [未处理的承诺拒绝:错误:预期的 URL 方案“http”或“https”但是“文件”]
问题描述
错误:[未处理的承诺拒绝:错误:预期的 URL 方案“http”或“https”但为“文件”]
我尝试在 react-native expo 项目中使用 pixi js。
这是 package.json 文件。
"dependencies": {
"@expo/vector-icons": "^9.0.0",
"expo": "^33.0.7",
"expo-asset-utils": "^1.1.1",
"expo-gl": "~5.0.1",
"expo-pixi": "^1.1.0",
"expokit": "^32.0.3",
"lodash": "^4.17.11",
"native-base": "^2.10.0",
"prop-types": "^15.6.2",
"react": "16.8.3",
"react-dom": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
"react-native-gesture-handler": "^1.0.9",
"react-native-svg": "^9.11.1",
"react-native-web": "^0.11.2",
"react-navigation": "^3.0.9",
"react-navigation-redux-helpers": "^2.0.9",
"react-redux": "^6.0.0",
"react-style-proptype": "^3.2.2",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"babel-preset-expo": "^5.0.0",
"expo-cli": "^2.10.1",
"eslint": "^5.16.0",
"eslint-config-universe": "^1.0.7",
"prettier": "^1.17.0"
},
"resolutions": {
"expo-pixi/@expo/browser-polyfill": "0.0.1-alpha.3"
},
"private": true
和 app.json 文件。
...
"privacy": "unlisted",
"sdkVersion": "33.0.0",
"platforms": [
"ios",
"android"
],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./src/assets/images/icon.png",
"splash": {
"image": "./src/assets/images/splash.png",
"resizeMode": "cover",
"backgroundColor": "#222222"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
}
...
这是我的屏幕代码。
import React from 'react';
import { GLView } from 'expo-gl';
import ExpoPixi,{ PIXI } from 'expo-pixi';
export default class GameReady extends React.Component {
render() {
return (
<GLView
style={{ flex: 1 }}
onContextCreate={async context => {
const sprite = await PIXI.Sprite.fromExpoAsync('https://ubisafe.org/images/sans-transparent-8-bit.png');
const app = new PIXI.Application({ context });
app.stage.addChild(sprite);
}}
/>
);
}
}
错误:
[Unhandled promise rejection: Error: Expected URL scheme 'http' or 'https' but was 'file']
Stack trace:
node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:155:41 in createErrorFromErrorData
node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:104:55 in <unknown>
node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:414:4 in __invokeCallback
node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:127:28 in <unknown>
node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:314:10 in __guard
node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:126:17 in invokeCallbackAndReturnFlushedQueue
...
我将这个项目作为博览会开始运行。但我得到了上述错误。我该如何解决这个问题?帮我。谢谢。
解决方案
请查看带有本地精灵和网络的固定零食示例:
推荐阅读
- excel - 如何将值转换为整数 VBA
- scala - `.delay` 或 `.map` 中抛出的异常的猫效应的预期行为
- python - 为什么这个while循环在if语句下不执行?
- c++ - Meson 选择了错误的编译器(GCC 而不是 clang)
- oop - 哪些模式可以帮助我组织具有模块化结构的大型项目?
- c# - 将集合绑定到 wpf 数据网格中的列
- reactjs - 错误:无法加载插件导入:部署 create-react-app 时找不到模块“eslint-plugin-import”
- ios - SWRevealViewcontroller UIbutton 动作第一次点击不起作用,之后它工作正常
- python-3.x - pycharm中的文件层次结构导致错误
- python - 如何在python环境中保存r对象输出