SyntaxError .../project/assets/images/logo.png: 意外字符 '�' (1:0)
SyntaxError .../project/assets/images/logo.png: Unexpected character '�' (1:0)
这看起来像是加载程序错误,但 Expo/CRNA 不应该默认支持 png 吗?
这是我的代码:
<View style={ styles.logo }>
<Image source={require('../assets/images/logo.png')} style={{ flex:1, width: 150, height: 150 }} />
</View>
logo: {
flex: 1,
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
height: 200,
},
我的图像是使用 expo.io 上的示例代码缓存的。这是我尝试的第一个资产。我该如何解决?我什至找不到任何加载程序配置。
好的,找到了。它不在我的代码中,但我删除了 Expo 应用程序,重新启动了 Expo XDE,错误消失了。
当您启用 'Hot reloading' 时会发生这种情况。每当您要更新项目中的图像时,请摇动设备从菜单中禁用热重新加载。
只要重新启动打包程序就可以解决这个问题。
参考:https://github.com/facebook/react-native/issues/6691#issuecomment-203073224
这看起来像是加载程序错误,但 Expo/CRNA 不应该默认支持 png 吗?
这是我的代码:
<View style={ styles.logo }>
<Image source={require('../assets/images/logo.png')} style={{ flex:1, width: 150, height: 150 }} />
</View>
logo: {
flex: 1,
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
height: 200,
},
我的图像是使用 expo.io 上的示例代码缓存的。这是我尝试的第一个资产。我该如何解决?我什至找不到任何加载程序配置。
好的,找到了。它不在我的代码中,但我删除了 Expo 应用程序,重新启动了 Expo XDE,错误消失了。
当您启用 'Hot reloading' 时会发生这种情况。每当您要更新项目中的图像时,请摇动设备从菜单中禁用热重新加载。
只要重新启动打包程序就可以解决这个问题。
参考:https://github.com/facebook/react-native/issues/6691#issuecomment-203073224