android react-native上的图像错误代码500

时间:2017-09-05 11:38:11

标签: android react-native

我想弄明白为什么会收到这个错误:

Error image

我使用了 `<View style={styles.Container}> <Image source={require('/Src/Img/Superman.png')} /> <Text style={styles.textContainer}> Welcome To Hero App </Text> <Text style={styles.subTitle}> The Best Place To Ask For Help :) </Text> <View style={styles.caseContainer}> <TextInput placeholder="Username" placeholderTextColor = 'rgba(255,255,255,0.7)' autoCorrect = {false} style={styles.input}/> <TextInput placeholder="Password" placeholderTextColor = 'rgba(255,255,255,0.7)' secureTextEntry style={styles.input} /> </View> ` ;这是官方网站教程中的代码。

我该如何解决这个问题? 这是我使用的代码:

function initializeMap() {
    map = new google.maps.Map(document.getElementById('map_canvas'), {
        zoom: 19,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });
    directionsDisplay.setMap(map);
    directionsDisplay.setPanel(document.getElementById('test'));
}
var pinColor = "6495ED";
var pinImage = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|" + pinColor,
    new google.maps.Size(21, 34),
    new google.maps.Point(0, 0),
    new google.maps.Point(10, 34));
var pinShadow = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_shadow",
    new google.maps.Size(40, 37),
    new google.maps.Point(0, 0),
    new google.maps.Point(12, 35));

function locError(error) {
    // the current position could not be located
    lat = 53.5409298;
    lng = -2.11136590000001;
    initializeMap();
    setCurrentPosition(position);
}

function setCurrentPosition(position) {
    if (position.coords.latitude) {
        lat = position.coords.latitude;
        lng = position.coords.longitude;
    } else {
        lat = 53.5409298;
        lng = -2.11136590000001;
    }
    var accuracy = position.coords.accuracy;
    currentPositionMarker = new google.maps.Marker({
        map: map,
        position: new google.maps.LatLng(
            lat,
            lng
        ),
        title: "Current Position",
        icon: pinImage,
        shadow: pinShadow,
        animation: google.maps.Animation.DROP
    });
    map.panTo(new google.maps.LatLng(
        lat,
        lng
    ));
    circle = new google.maps.Circle({
        map: map,
        radius: accuracy,
              strokeColor: '#E62C56',
              strokeOpacity: 0.8,
              strokeWeight: 2,
              fillColor: '#6495ED',
              fillOpacity: 0.10
    });

    circle.bindTo('center', currentPositionMarker, 'position')
    algolia_search(position);
}

function displayAndWatch(position) {
    // set current position
    setCurrentPosition(position);
    // watch position
    watchCurrentPosition(position);
}

function watchCurrentPosition(position) {
    var positionTimer = navigator.geolocation.watchPosition(
        function (position) {
            setMarkerPosition(
                currentPositionMarker,
                position,
            )
        });
}

function setMarkerPosition(marker, position) {
    circle.setRadius(position.coords.accuracy);
    marker.setPosition(
        new google.maps.LatLng(
            lat,
            lng)
    );
    algolia_search(position);
}

function initLocationProcedure() {
    initializeMap();
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(displayAndWatch, locError);
    } else {
        displayAndWatch();
        locError();
    }
}

function clearOverlays() {
    for (var i = 0; i < markers.length; i++) {
        markers[i].setMap(null);
    }
    markers.length = 0;
}
$(document).ready(function () {
    initLocationProcedure();
});

2 个答案:

答案 0 :(得分:0)

你必须在组件道具上使用“=”而不是“:”:

<Image source={require('./Path')} />

答案 1 :(得分:0)

对不起伙计们,我发现路径错了,正确答案是:<Image source={require('../../Path')} />

谢谢大家的时间