最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

老師,前端商品列表頁(yè)跳轉(zhuǎn)到商品詳情頁(yè)后id傳不過(guò)去,我自己搞了大半天了找不出來(lái)坑在哪

/******************這是商品列表頁(yè)************************/

<html>

<head>

<meta charset="utf-8">

<link href="static/assets/global/plugins/bootstrap/css/bootstrap.min.css" style="stylesheet" type="text/css"/>

<link href="static/assets/global/css/components.css" rel="stylesheet" type="text/css"/>

<link href="static/assets/admin/pages/css/login.css" rel="stylesheet" type="text/css"/>

<script src="static/assets/global/plugins/jquery-1.11.0.min.js" type="text/javascript"></script>


</head>

<body>

<div class="content">

<h3 class="form-title">商品列表瀏覽</h3>

<div class="table-responsive">

<table class="table">

<thead>

<tr>

<th>商品名</th>

<th>商品圖片</th>

<th>商品描述</th>

<th>商品價(jià)格</th>

<th>商品庫(kù)存</th>

<th>商品銷量</th>

</tr>

</thead>

<tbody id="container">

</tbody>

</table>

</div>

</div>

</body>


<script>

//定義全局商品數(shù)組信息

var g_itemList = [];

jQuery(document).ready(function(){

$.ajax({

type:"GET",

url:"http://localhost:8090/item/list",

xhrFields:{withCredentials:true},

success:function(data){

if(data.status == "success"){

g_itemList = data.data;

reloadDom();

}else{

alert("獲取商品信息失敗,原因?yàn)? + data.data.errMsg);

}

},

error:function(data){

alert("獲取商品信息失敗,原因?yàn)?" + data.responseText);

},

});

});


function reloadDom() {

for (var i = 0; i < g_itemList.length; i++) {

var itemVO = g_itemList[i];

var dom = "<tr data-id=''+itemVO.id'' id='itemDetail"+itemVO.id+"'><td>"+itemVO.title+"</td><td><img style='width:100px;height:auto;' src='"+itemVO.imgUrl+"'/></td><td>"+itemVO.description+"</td><td>"+itemVO.price+"</td><td>"+itemVO.stock+"</td><td>"+itemVO.sales+"</td></tr>";

$("#container").append(dom);


$("#itemDetail"+itemVO.id).on("click",function(e) {

window.location.href="getitem.html?id="+$(this).data("id");

});

}

}

</script>

</html>


/******************這是商品詳情頁(yè)**********************/

<html>

<head>

<meta charset="utf-8">

<link href="static/assets/global/plugins/bootstrap/css/bootstrap.min.css" style="stylesheet" type="text/css"/>

<link href="static/assets/global/css/components.css" rel="stylesheet" type="text/css"/>

<link href="static/assets/admin/pages/css/login.css" rel="stylesheet" type="text/css"/>

<script src="static/assets/global/plugins/jquery-1.11.0.min.js" type="text/javascript"></script>


</head>

<body class="login">

<div class="content">

<h3 class="form-title">商品詳情</h3>

<div class="form-group">

<label class="control-label">商品名</label>

<div>

<input class="control-label" id="title"/>

</div>

</div>



<div class="form-group">

<label class="control-label">商品描述</label>

<div>

<input class="control-label" id="description"/>

</div>

</div>


<div class="form-group">

<label class="control-label">商品價(jià)格</label>

<div>

<input class="control-label" id="price"/>

</div>

</div>



<div class="form-group">

<label class="control-label">圖片地址</label>

<div>

<img sytle:'width:200px;height:auto' id="imgUrl"/>

</div>

</div>



<div class="form-group">

<label class="control-label">庫(kù)存</label>

<div>

<input class="control-label" id="stock"/>

</div>

</div>


<div class="form-group">

<label class="control-label">銷量</label>

<div>

<input class="control-label" id="sales"/>

</div>

</div>

</div>

</body>


<script>

function getParam(paramName) { ?

? ?paramValue = "", isFound = !1; ?

? ?if (this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=") > 1) { ?

? ? ? ?arrSource = unescape(this.location.search).substring(1, this.location.search.length).split("&"), i = 0; ?

? ? ? ?while (i < arrSource.length && !isFound) arrSource[i].indexOf("=") > 0 && arrSource[i].split("=")[0].toLowerCase()?

? ? ? ? == paramName.toLowerCase() && (paramValue = arrSource[i].split("=")[1], isFound = !0), i++ ?

? ?} ?

? ?return paramValue == "" && (paramValue = null), paramValue ?

}?


var g_itemVO = {};

jQuery(document).ready(function(){

//獲取商品詳情

$.ajax({

type:"GET",

url:"http://localhost:8090/item/get",

data:{

"id":getParam("id"),

// "id":5,

},

xhrFields:{withCredentials:true},

success:function(data){

if(data.status == "success"){

g_itemVO = data.data;

reloadDom();

}else{

alert("獲取信息失敗,原因?yàn)? + data.data.errMsg);

}

},

error:function(data){

alert("獲取信息失敗,原因?yàn)?" + data.responseText);

},

});

});


function reloadDom() {

$("#title").text(g_itemVO.title);

$("#description").text(g_itemVO.description);

$("#stock").text(g_itemVO.stock);

$("#price").text(g_itemVO.price);

$("#imgUrl").attr("src",g_itemVO.imgUrl);

$("#sales").text(g_itemVO.sales);

}

</script>

</html>

https://img1.sycdn.imooc.com//5c1b057600011cd413380383.jpg

正在回答

2 回答

瀏覽器端調(diào)試下商品詳情頁(yè)的js有沒(méi)有報(bào)錯(cuò),有沒(méi)有正確的取到id字端

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

麻了一一一 提問(wèn)者

已經(jīng)解決了,謝謝老師!
2018-12-24 回復(fù) 有任何疑惑可以回復(fù)我~

先檢查一下 商品詳情頁(yè)面的js有沒(méi)有報(bào)錯(cuò)

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

老師,前端商品列表頁(yè)跳轉(zhuǎn)到商品詳情頁(yè)后id傳不過(guò)去,我自己搞了大半天了找不出來(lái)坑在哪

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)