React-Native Expo不呈现图像

时间:2019-07-15 13:16:59

标签: react-native expo

我正在使用Expo来学习一些基本的React Native技能,但是当我尝试渲染图像时却遇到其他地方找不到的问题。

我的代码如下:

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Image from 'react-native-web/dist/exports/Image'

export default class App extends React.Component {
  render () {
    return (
      <View>
        <Image source={require("./reactLogo.png")}/> //Using {{uri:link}} doesnt work
        <Text>Live development on iOS</Text>
        <Text>Demonstration Application</Text>
      </View>
    );
  }
}

但是,当我运行此命令(expo start)时,出现此错误:

TypeError: undefined is not an object (evaluating 'asset.scales')

This error is located at:
    in Image (at App.js:10)
    in RCTView (at View.js:45)
    in View (at App.js:9)
    in App (at withExpoRoot.js:20)
    in RootErrorBoundary (at withExpoRoot.js:19)
    in ExpoRootComponent (at renderApplication.js:35)
    in RCTView (at View.js:45)
    in View (at AppContainer.js:98)
    in RCTView (at View.js:45)
    in View (at AppContainer.js:115)
    in AppContainer (at renderApplication.js:34)

Stack trace:
  node_modules/react-native-web/dist/exports/Image/index.js:75:22 in resolveAssetUri
  node_modules/react-native-web/dist/exports/Image/index.js:234:30 in Image
  node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:7324:26 in constructClassInstance
  node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:11479:6 in updateClassComponent
  node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:17276:21 in performUnitOfWork
  node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:17316:41 in workLoop
  node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:17417:15 in renderRoot
  node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:18423:17 in performWorkOnRoot
  node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:18324:24 in performWork
  node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:18285:14 in performSyncWork
  node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:18169:19 in requestWork
  node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:17969:16 in scheduleWork
  node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:18642:15 in scheduleRootUpdate
  node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:19512:20 in render
  node_modules/react-native/Libraries/ReactNative/renderApplication.js:61:52 in renderApplication
  node_modules/react-native/Libraries/ReactNative/AppRegistry.js:104:10 in run
  node_modules/react-native/Libraries/ReactNative/AppRegistry.js:198:26 in runApplication
  node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:366:47 in __callFunction
  node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:106:26 in <unknown>
  node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:314:10 in __guard
  node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:105:17 in callFunctionReturnFlushedQueue

我不确定如何解决此问题,如果删除图像,我将不再收到错误,一切似乎都可以正常工作。我想念什么?

0 个答案:

没有答案