gpt4 book ai didi

react-native - [未处理的 promise 拒绝 : Error: Expected URL scheme 'http' or 'https' but was 'file' ]

转载 作者:行者123 更新时间:2023-12-04 04:54:08 25 4
gpt4 key购买 nike

错误:
[未处理的 promise 拒绝:错误:预期的 URL 方案为“http”或“https”,但为"file"]

我尝试在 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
...

我在博览会开始时运行这个项目。
但我得到了上述错误。
我该如何解决这个问题?
帮我。
谢谢。

最佳答案

请查看本地 Sprite 和网络上的固定小吃示例:

https://snack.expo.io/@djalik/base-pixi.js

关于react-native - [未处理的 promise 拒绝 : Error: Expected URL scheme 'http' or 'https' but was 'file' ],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58240125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com