第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

數(shù)據(jù)明明已經(jīng)有返回了,但是列表就是不顯示

網(wǎng)上的解決辦法要不就是code對(duì)應(yīng)的值改成0,再要不就是還需要response參數(shù)。都試過了沒有用,我的值還是沒展示。實(shí)在是找不到問題在哪里,求幫助~~~


customer.js文件

table=layui.table;

table.render({
????elem:?,
????url:?,??page:?,???response:{?statusName:?,
????????statusCode:?},
????cols:?[[?{field:,title:},
????????{field:,title:},
????????{field:,title:},
????????{field:,title:},
????????{field:,title:},
????????{title:,toolbar:}
????]],
????parseData:(res){{
????????????:?res.code,?:?res.msg,???:?res.data.records,???:?res.data.count????}
????}
});


controller文件:
package?com.imooc.project.controller;


import?com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import?com.baomidou.mybatisplus.core.toolkit.StringUtils;
import?com.baomidou.mybatisplus.core.toolkit.Wrappers;
import?com.baomidou.mybatisplus.extension.api.R;
import?com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import?com.imooc.project.entity.Customer;
import?com.imooc.project.service.CustomerService;
import?org.springframework.beans.factory.annotation.Autowired;
import?org.springframework.web.bind.annotation.GetMapping;
import?org.springframework.web.bind.annotation.RequestMapping;

import?org.springframework.stereotype.Controller;
import?org.springframework.web.bind.annotation.ResponseBody;

import?java.util.HashMap;
import?java.util.Map;

/**
?*?<p>
?*?客戶表?前端控制器
?*?</p>
?*
?*?@author?xigua
?*?@since?2023-04-19
?*/
@Controller
@RequestMapping("/customer")
public?class?CustomerController?{

????@Autowired
????private?CustomerService?customerService;

????/**
?????*?進(jìn)入列表頁
?????*?@return
?????*/
????@GetMapping("toList")
????public?String?toList(){
????????return?"/customer/customerList";
????}

????/**
?????*?查詢方法
?????*?@param?realName
?????*?@param?phone
?????*?@param?page
?????*?@param?limit
?????*?@return
?????*/
????@GetMapping("list")
????@ResponseBody
????public?R<Map<String,Object>>?list(String?realName,String?phone,Long?page,Long?limit){
????????//查詢條件:當(dāng)realName不為空時(shí),加上模糊查詢;當(dāng)電話號(hào)碼不為空時(shí),加上模糊查詢
????????//并且customerID按照倒序排列
????????LambdaQueryWrapper<Customer>?wrapper=?Wrappers.<Customer>lambdaQuery()
????????????????.like(StringUtils.isNotBlank(realName),Customer::getRealName,realName)
????????????????.like(StringUtils.isNotBlank(phone),Customer::getPhone,phone)
????????????????.orderByDesc(Customer::getCustomerId);

????????//分頁查詢
????????Page<Customer>?customerPage?=?customerService.page(new?Page<>(page,?limit),?wrapper);

????????HashMap<String,?Object>?data?=?new?HashMap<>();
????????data.put("count",customerPage.getTotal());
????????data.put("records",customerPage.getRecords());

????????return?R.ok(data);
????}


}

customerList.html文件
<!DOCTYPE?html>
<html?lang="zh"?xmlns:th="http://www.thymeleaf.org">
<head>
<meta?charset="UTF-8">
???<link?rel="stylesheet"?th:href="@{/webjars/layui/css/layui.css}"?media="all">
</head>
<body>

???<div?class="layui-form-item">

??????<div?class="layui-inline">
?????????<label?class="layui-form-label">真實(shí)姓名</label>
?????????<div?class="layui-input-inline"?style="width:?150px;">
????????????<input?type="text"?id="realName"?autocomplete="off"?class="layui-input">
?????????</div>
??????</div>

??????<div?class="layui-inline">
?????????<label?class="layui-form-label">手機(jī)號(hào)碼</label>
?????????<div?class="layui-input-inline"?style="width:?150px;">
????????????<input?type="text"?id="phone"?autocomplete="off"
?class="layui-input">
?????????</div>
??????</div>

??????<div?class="layui-inline">
?????????<div?class="layui-input-inline">
????????????<button?class="layui-btn">查詢</button>
?????????</div>
??????</div>

???</div>

???<button?class="layui-btn">增加</button>

???<table?id="customerList"></table>
???<script?th:src="@{/webjars/layui/layui.all.js}"></script>
???<script?th:src="@{/webjars/jquery/jquery.js}"></script>
???<script?th:src="@{/js/customer/customer.js}"></script>
???<script?type="text/html"?id="barDemo">
??????<a?class="layui-btn?layui-btn-xs"?lay-event="detail">查看</a>
??????<a?class="layui-btn?layui-btn-xs"?lay-event="edit">編輯</a>
??????<a?class="layui-btn?layui-btn-danger?layui-btn-xs"?lay-event="del">刪除</a>
???</script>


</body>
</html>


正在回答

1 回答

家人們我找了一下午,我感覺就是我請(qǐng)求成功了,但是解析數(shù)據(jù)有問題。

然后我試了一下會(huì)不會(huì)是后端沒有返回count,然后前端沒法獲取總數(shù)條數(shù),所以沒法賦值給res.data.count

然后我在customer.js里面?zhèn)髁诉@行代碼

res.data.count=res.data.length;

家人們誰懂啊,沒想到成功了

http://img1.sycdn.imooc.com//645b5ff50001b7a818830759.jpg

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

qq_31畫_0 提問者

還有更離譜的事情,我用了上面的那行代碼成功了之后,我疑惑有什么區(qū)別,明明controller層后端有獲取count的值。我再次把我上面那行又注釋掉了,結(jié)果數(shù)據(jù)就一直是對(duì)的,離大譜,不知道怎么回事
2023-05-10 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

數(shù)據(jù)明明已經(jīng)有返回了,但是列表就是不顯示

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

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

幫助反饋 APP下載

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

公眾號(hào)

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