React Native公式チュートリアルのScrollView
の参照を受けました。 500 URL:http://10.0.2.2:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false 本体:画像が存在しないエラー
{"from":"F:\\ReactNativeProject\\FirstProject\\index.android.js","to":"./img/favicon.png","message":"Unable to resolve module `./img/favicon.png` from `F:\\ReactNativeProject\\FirstProject\\index.android.js`: Directory F:\\ReactNativeProject\\FirstProject\\img\\favicon.png doesn't exist","name":"UnableToResolveError","type":"UnableToResolveError","errors":[{}]}
だけ <Image source={require('./img/favicon.png')} />
のような画像コードに私はそれを構築しよう
が開発サーバーが応答エラーコードを返したことを示しています画像をフォルダに設定します。F:\ReactNativeProject\FirstProject\img
イメージ名はfavicon
なぜこのようなエラーが表示されますか?なぜ私に言うことができますか?ありがとうございました。
新しいエラーF:/ReactNativeProject/FirstProject/index.android.js: Unexpected token (9:25) at F:\ReactNativeProject\FirstProject\index.android.js:9:25
私のコードは
import React, { Component } from 'react';
import{ AppRegistry, ScrollView, Image, Text, View } from 'react-native'
class IScrolledDownAndWhatHappenedNextShockedMe extends Component {
render() {
return(
<ScrollView>
<Image source={../../img/favicon.png} />
</ScrollView>
);
}
}
AppRegistry.registerComponent('FirstProject',() => IScrolledDownAndWhatHappenedNextShockedMe);
おかげで、私はそれを得ることはありません。
はする必要があります。私のルートが 'F:\ ReactNativeProject \ FirstProject \ img'であれば私の場合は' 'のようにしてください。それは最後に失敗する。 –
try <画像ソース= {../../ img/favicon.png} />または<画像ソース= {../../../ img/favicon.png} /> – Ved
ありがとうございました。それと一緒に変わるが、それは別のエラーを示す、私は反応ネイティブのbignnerだ、もう一度私を助けてくれますか?ありがとう。 –