<template> <view class='commodity-List'> <Commodity :dataList='commodityList'></Commodity> </view> </template> <script> import Commodity from './Commodity.vue' export default { data() { return { commodityList: [{ id: 1, imgUrl: "../../static/img/格子衫.webp", name: "便宜大衣快来买啦,不买后悔呀!为了不后悔,一定要买呀!!!", pprice: "299", oprice: "466", discount: "5.6折" }, { id: 2, imgUrl: "../../static/img/短袖.jpg", name: "便宜大衣快来买啦,不买后悔呀!为了不后悔,一定要买呀!!!", pprice: "299", oprice: "466", discount: "5.6折" }] } } } </script> uniapp不显示内容
时间: 2024-04-12 08:31:37 浏览: 88
根据您提供的代码,我看不出任何明显的问题。但是,您可能需要确保在使用`Commodity`组件之前,已经正确导入并在`components`选项中注册。请确保在`export default`之前添加以下代码:
```javascript
components: {
Commodity
},
```
如果您已经添加了这段代码但问题仍然存在,请提供更多关于您的问题的详细信息或错误消息,这样我可以更好地帮助您解决问题。
相关问题
<template> <view class='commodity-List'> <Commodity :dataList:'commodityList'></Commodity> </view> </template> <script> import Commodity from './Commodity.vue' export default { data() { return { commodityList: [{ id: 1, imgUrl: "../../static/img/格子衫.webp", name: "便宜大衣快来买啦,不买后悔呀!为了不后悔,一定要买呀!!!", pprice: "299", oprice: "466", discount: "5.6折" }, { id: 2, imgUrl: "../../static/img/短袖.jpg", name: "便宜大衣快来买啦,不买后悔呀!为了不后悔,一定要买呀!!!", pprice: "299", oprice: "466", discount: "5.6折" }] } },,uniapp报错
根据提供的代码片段,我注意到脚本部分存在一个额外的逗号(,)。请尝试移除最后一个逗号,并再次运行代码。以下是修正后的代码:
```javascript
<template>
<view class='commodity-List'>
<Commodity :dataList='commodityList'></Commodity>
</view>
</template>
<script>
import Commodity from './Commodity.vue'
export default {
data() {
return {
commodityList: [{
id: 1,
imgUrl: "../../static/img/格子衫.webp",
name: "便宜大衣快来买啦,不买后悔呀!为了不后悔,一定要买呀!!!",
pprice: "299",
oprice: "466",
discount: "5.6折"
}, {
id: 2,
imgUrl: "../../static/img/短袖.jpg",
name: "便宜大衣快来买啦,不买后悔呀!为了不后悔,一定要买呀!!!",
pprice: "299",
oprice: "466",
discount: "5.6折"
}]
}
}
}
</script>
```
请尝试更新代码并重新运行,看看问题是否得到解决。如果问题仍然存在,请提供详细的错误信息以便更好地帮助您解决问题。
这是一段jquery代码,请帮我修改为,如果五秒内链接不到服务器则打印"未找到服务器": $.post("http://localhost:8080/xxxx/home.do",temp, function(data) { let com = document.getElementById("commodity_row"); let card = ``; $.each(data, function(i, v) { card += ` <div class="col-xl-2 col-lg-3 col-md-3 col-sm-4 col-6 mb-2"> <div class="card card_aive cur-poi card_color"> <img src="http://localhost:8080/xxxx/${v.g_Pic}" class="card-img-top " > <div class="card-body"> <span class="card-text">${v.g_Name}</span> <p class="card-text font-size-12 color-red">${v.gCategories_Id.c_Name}</p> <p id="price" class="card-text text-right color-red">¥${v.g_Money}</p> </div> </div> </div>`; }) com.innerHTML = card; }, "json");
你可以使用setTimeout函数来实现五秒钟后未链接成功则打印“未找到服务器”的效果,代码如下:
```javascript
$.ajax({
url: "http://localhost:8080/xxxx/home.do",
type: "POST",
data: temp,
dataType: "json",
success: function(data) {
let com = document.getElementById("commodity_row");
let card = ``;
$.each(data, function(i, v) {
card += ` <div class="col-xl-2 col-lg-3 col-md-3 col-sm-4 col-6 mb-2">
<div class="card card_aive cur-poi card_color">
<img src="http://localhost:8080/xxxx/${v.g_Pic}" class="card-img-top " >
<div class="card-body">
<span class="card-text">${v.g_Name}</span>
<p class="card-text font-size-12 color-red">${v.gCategories_Id.c_Name}</p>
<p id="price" class="card-text text-right color-red">¥${v.g_Money}</p>
</div>
</div>
</div>`;
});
com.innerHTML = card;
},
error: function(jqXHR, textStatus, errorThrown) {
setTimeout(function() {
console.log("未找到服务器");
}, 5000);
}
});
```
这里使用了$.ajax()函数来发送请求,并在请求失败时使用setTimeout函数来实现五秒钟后打印“未找到服务器”的效果。
阅读全文