2016-11-23 121 views
0

我有一个img,正确显示在主页上,但是当我导航到其他页面时,图像不会显示在我的手机上。在浏览器中,它按预期显示图像。我真的不知道是什么问题...科尔多瓦 - jquery手机img路径

这是JavaScript代码,我追加的HTML表:

var imgPath = '../img/icons/notification_bell.png'; 

html = html + "<tr><td class='img-table'><img src=" + imgPath + "/></td>" + "<td><span class='time-aside'><strong>" + formattedTime + "</strong></span><h4>" + info.data[count][1] + "</h4><p>" + info.data[count][2] + "</p></td></tr>"; 

,这是HTML:

<div data-role="page" id="all"> 
    <div data-role="header"> 
     <a href="#dashboard" class="ui-btn ui-icon-carat-l ui-btn-icon-notext ui-alt-icon ui-corner-all ui-btn-left" data-transition="slide" data-direction="reverse">No text</a> 
     <h1>All Reminders</h1> 
    </div> 

     <div data-role="main" class="ui-content" data-theme="b"> 
     <table data-role="table" data-mode="column" id="notificationTable" class="ui-responsive"> 
      <tbody> 
      </tbody> 
      </table> 
      <a class="clearbtn" style="text-decoration: none"><button>clear</button></a> 
     </div> 
     </div> 

当我检查图像与chrome://inspect/我得到这个错误:

/img/icons/notification_bell.png/:1 GET file:///img/icons/notification_bell.png/ net::ERR_FILE_NOT_FOUND 

当我将其设置手动为t他相同的路径上这样的仪表盘:'img/icons/notification_bell.png'它显示了,但是当我通过JS做它不显示...

回答

1

如果你的应用程序是在根文件夹,尽量只放:

var imgPath = 'img/icons/notification_bell.png';