我真的很想明白爲什麼不是我的列表加載。 這是我的json和jquery,以及我的HTML。 控制檯顯示0錯誤,列表只顯示空白。我非常感謝一些幫助,我是這個json的新手。提前謝謝了!爲什麼不是我的json產品列表加載?
// Json array
var productList = {"products": [
{"description": "Bata Bordada", "color": "amarelo", "size":"P", "price": "390"},
{"description": "Chapéu de Praia com Fivela", "color": "cinza", "size":"M", "price": "390"},
{"description": "Vestido Texturizado", "color": "branco", "size":"G", "price": "390"},
{"description": "Bata Bordada", "color": "branco", "size":"GG", "price": "390"},
{"description": "Chapéu de Praia com Fivela", "color": "amarelo", "size":"36", "price": "390"},
{"description": "Vestido Texturizado", "color": "azul", "size":"38", "price": "390"},
{"description": "Bata Bordada", "color": "cinza", "size":"40", "price": "390"},
{"description": "Chapéu de Praia com Fivela", "color": "branco", "size":"42", "price": "390"},
{"description": "Vestido Texturizado", "color": "cinza", "size":"44", "price": "390"}
]
};
function loadList() {
var list = $("#ProductList").listview();
list.sort();
$(productList.products).each(function(index){
$(list).append(
'<li class="product-it"> <article class="product"> <span class="prd-img-wrapper"> <img class="prd-img" src="img/vestido1.jpg"></span> <h2 class="prd-tit">' + this.description + '</h2> <span class="prd-wrap"><span class="prd-price"><span class="prd-prc">' + this.price + '</span></br> <span class="prd-par">até 5x de R$30,00</span></span><a class="prd-cart" href="#">Adicionar ao carrinho.</a></span></article></li>');
});
$(list).listview("refresh");
}
<!DOCTYPE HTML>
<html lang="pt-br">
<head>
<meta charset="utf-8"/>
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<title>Teste Vaga Front End</title>
<link href="css/style.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
<script src="js/js.js"></script>
</head>
<body onLoad="loadList()">
<section class="products">
<header class="products-hdr">
<h3 class="mobile-btn order">Ordenar</h3>
<select class="prd-order">
<option value="MaisRecentes">Mais Recentes</option>
<option value="MaiorPreco">Maior Preço</option>
<option value="MenorPreco">Menor Preço</option>
</select>
</header>
<ul id="ProductList" class="product-lt"> \t \t \t \t
</ul>
</section>
</body>
</html>
什麼是'listview' – brk
另外我有點絕望,因爲我必須提供此代碼運行週一^ _^ –
@ user2181397你讓我。我不知道。我只是從其他地方複製代碼,只是改變了變量以適應我的需求:(我甚至沒有注意到這個listview的東西...... :( –