this->bookId = id;

时间: 2024-04-27 11:20:32 浏览: 12
this->bookId = id; 是 C++ 中的一种语法,表示将当前对象的 bookId 成员变量赋值为 id 变量的值。 this 是一个指向当前对象的指针,可以用于访问当前对象的成员变量和成员函数。在类的成员函数中,可以使用 this 关键字来引用当前对象的成员变量和成员函数。 bookId 是 Book 类的一个成员变量,表示图书的编号。id 是该函数的一个参数,表示要设置的图书编号。通过 this->bookId = id; 语句,我们将当前对象的 bookId 成员变量赋值为 id 变量的值,从而设置图书的编号。
相关问题

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>图书商城-图书列表</title> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <link rel="stylesheet" href="/BookShopSystem_war/layui/css/layui.css"> <link rel="stylesheet" href="/BookShopSystem_war/static/css/index.css"> <script src="https://cdn.bootcss.com/vue/2.5.16/vue.min.js"></script> <script src="https://unpkg.com/axios/dist/axios.min.js"></script> </head> <body> <div id="app"> <div class="layui-container"> <div class="hot-sell" v-if="bookAll.length > 0"> <div class="layui-row layui-col-space20"> <table> <tr> <td v-for="(bk,index) in currentBookAll" :key="index" class="layui-col-xs2" style="margin-left: 30px"> <a :href="'detail?id='+bk.bookId" class="text"> <div><img :src="'/BookShopSystem_war/' + bk.image1"></div> <p>{{bk.bookName}}</p> <p class="price">¥{{bk.bookPrice}}</p> </a> </td> </tr> </table> </div> </div> </div> <div id="houseList"></div> </div> <!-- 引入尾部footer.html --> <iframe src="footer.html" frameborder="0" scrolling="no" width="100%" height="245px"></iframe> </div> <script src="/BookShopSystem_war/layui/layui.js"></script>这是完整的html代码,请结合你给出的分页功能整合出完整的代码

好的,以下是结合分页功能的完整代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>图书商城-图书列表</title> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <link rel="stylesheet" href="/BookShopSystem_war/layui/css/layui.css"> <link rel="stylesheet" href="/BookShopSystem_war/static/css/index.css"> <script src="https://cdn.bootcss.com/vue/2.5.16/vue.min.js"></script> <script src="https://unpkg.com/axios/dist/axios.min.js"></script> </head> <body> <div id="app"> <div class="layui-container"> <div class="hot-sell" v-if="bookAll.length > 0"> <div class="layui-row layui-col-space20"> <table> <tr> <td v-for="(bk,index) in currentBookAll" :key="index" class="layui-col-xs2" style="margin-left: 30px"> <a :href="'detail?id='+bk.bookId" class="text"> <div><img :src="'/BookShopSystem_war/' + bk.image1"></div> <p>{{bk.bookName}}</p> <p class="price">¥{{bk.bookPrice}}</p> </a> </td> </tr> </table> </div> </div> <div class="layui-row"> <div class="layui-col-md12"> <div id="pagination"></div> </div> </div> </div> <div id="houseList"></div> <!-- 引入尾部footer.html --> <iframe src="footer.html" frameborder="0" scrolling="no" width="100%" height="245px"></iframe> </div> <script src="/BookShopSystem_war/layui/layui.js"></script> <script> layui.use('laypage', function(){ var laypage = layui.laypage; var vm = new Vue({ el: '#app', data: { bookAll: [], current: 1, totalPage: 1, currentBookAll: [] }, mounted: function() { var _this = this; axios.get('/BookShopSystem_war/book/all') .then(function(response) { _this.bookAll = response.data; _this.totalPage = Math.ceil(_this.bookAll.length / 10); _this.currentBookAll = _this.bookAll.slice(0, 10); laypage.render({ elem: 'pagination', count: _this.bookAll.length, curr: _this.current, limit: 10, layout: ['prev', 'page', 'next', 'skip'], jump: function(obj, first){ if(!first){ _this.currentBookAll = _this.bookAll.slice((obj.curr-1)*obj.limit, obj.curr*obj.limit); } } }); }) .catch(function(error) { console.log(error); }); } }); }); </script> </body> </html> 注意:这里的分页功能使用了 layui 的 laypage 组件,需要在页面中引入 layui.js 和 layui.css,并且需要在 Vue 的 mounted 钩子函数中调用 laypage.render() 方法来渲染分页组件。同时,需要注意在分页回调函数中更新当前显示的数据。

Intent intent=this.getIntent(); bookId=intent.getStringExtra("bookId"); sendID=intent.getStringExtra("id");bookId为空

这段代码中,bookId为空的原因可能是intent对象中不存在名为"bookId"的字符串Extra,或者该Extra的值为null。建议在调用getStringExtra()方法前先检查intent对象中是否包含该Extra,或者给bookId变量赋一个默认值,以免出现空指针异常。例如可以这样修改代码: ``` Intent intent = this.getIntent(); if(intent.hasExtra("bookId")) { bookId = intent.getStringExtra("bookId"); } else { bookId = "default_book_id"; } sendID = intent.getStringExtra("id"); ```

相关推荐

package com.demo.bean; public class Book {//教材 private long id; private String bookId;//教材ID private String name;//教材名称 private String price;//价格 private String author;//编者 private String publisher;//出版社 private String profession;//专业 private String channel;//渠道 private String appendix;//备注 public Book() {} public Book(long id, String bookId, String name, String price, String author, String publisher, String profession, String channel, String appendix) { this.id = id; this.bookId = bookId; this.name = name; this.price = price; this.author = author; this.publisher = publisher; this.profession = profession; this.channel = channel; this.appendix = appendix; } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getBookId() { return bookId; } public void setBookId(String bookId) { this.bookId = bookId; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPrice() { return price; } public void setPrice(String price) { this.price = price; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } public String getPublisher() { return publisher; } public void setPublisher(String publisher) { this.publisher = publisher; } public String getProfession() { return profession; } public void setProfession(String profession) { this.profession = profession; } public String getChannel() { return channel; } public void setChannel(String channel) { this.channel = channel; } public String getAppendix() { return appendix; } public void setAppendix(String appendix) { this.appendix = appendix; } @Override public String toString() { return "Book [id=" + id + ", bookId=" + bookId + ", name=" + name + ", price=" + price + ", author=" + author + ",

{{ data.bookName }} {{ data.bookAuthor }} {{ data.bookPublish }} {{ data.price }} <input type="text" :value="data.num" readonly class="cOnt"> ¥{{data.total}} 删除 new Vue({ el: '#app', data: { userId: '', list: [] // list: [ // {userId:null,bookName:"图书1",image1:"/BookShopSystem_war/cart/xzwxz.png",price:50,num:2}, // {userId:null,bookName:"图书2",image1:"/BookShopSystem_war/cart/xzwxz.png",price:50,num:1}, // {userId:null,bookName:"图书3",image1:"/BookShopSystem_war/cart/xzwxz.png",price:50,num:2} // ] }, //选择或不选择一项 $(".xzWxz").click(function () { if ($(this).hasClass("on")) { $(this).removeClass("on"); } else { $(this).addClass("on"); } var ty = $(".xzWxz.on").length; $(".sXd1").find("font").html(ty); if (ty == es) { $(".ifAll").addClass("on"); } else { $(".ifAll").removeClass("on"); } jsZj(); }); 当我使用未被注释的list, 该代码点击后没有变化,而我使用注释的静态list数组,该代码点击有变化,为什么,未注释的list是能获取到数据并遍历了出来,如何解决

{{ collect.bookName }} ¥{{ collect.bookPrice }} <button @click="delCollect()"> × </button> new Vue({ el: "#app", data: { userId: '', collectBook: [] }, mounted() { var _this = this; axios.get('/BookShopSystem_war/getUserId') .then((response) => { this.userId = response.data; var userId = this.userId; // 将userId赋值给一个变量 axios({ method: 'get', url: 'http://localhost:8080/BookShopSystem_war/getCollectBook/' + userId }).then(function (result) { var code = result.data.code; var data = result.data.data; if (code == 200) { _this.collectBook = data; } console.log(data) }) }) .catch((error) => { console.log(error); }); }, methods: { delCollect() { var _this = this; axios({ method: "delete", url: "http://localhost:8080/BookShopSystem_war/deleteCollect", data: { userId: _this.userId, bookId: _this.collectBook.bookId } }).then(resp => { alert("取消收藏"); }) } }该取消收藏方法有错,给出原因并纠正

这是前端代码 {{ collect.bookName }} ¥{{ collect.bookPrice }} <button @click="delCollect(collect.bookId)"> × </button> new Vue({ el: "#app", data: { userId: '', collectBook: [] }, mounted() { var _this = this; axios.get('/BookShopSystem_war/getUserId') .then((response) => { this.userId = response.data; var userId = this.userId; // 将userId赋值给一个变量 axios({ method: 'get', url: 'http://localhost:8080/BookShopSystem_war/getCollectBook/' + userId }).then(function (result) { var code = result.data.code; var data = result.data.data; if (code == 200) { _this.collectBook = data; } console.log(data) }) }) .catch((error) => { console.log(error); }); }, methods: { delCollect(bookId) { var _this = this; axios({ method: "delete", url: "http://localhost:8080/BookShopSystem_war/deleteCollect", data: { userId: _this.userId, bookId: bookId } }).then(resp => { alert("取消收藏"); // 从 collectBook 数组中移除被删除的收藏 _this.collectBook = _this.collectBook.filter(collect => collect.bookId !== bookId); 请分析逻辑是否有误

最新推荐

recommend-type

通过 Matlab 测试共轭和双共轭梯度算法.zip

通过 Matlab 测试共轭和双共轭梯度算法.zip
recommend-type

基于卡尔曼估计温湿度的MATLAB程序-带交互-真实值可自己输入

背景:一维卡尔曼滤波的MATLAB例程,​背景为温度估计。 代码介绍:运行程序后,可以自己输入温度真实值 滤波前的值和滤波后的值分别于期望值(真实值)作差,可以得到​误差​曲线图 更多介绍:https://blog.csdn.net/callmeup/article/details/139374191
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

MATLAB柱状图在信号处理中的应用:可视化信号特征和频谱分析

![matlab画柱状图](https://img-blog.csdnimg.cn/3f32348f1c9c4481a6f5931993732f97.png) # 1. MATLAB柱状图概述** MATLAB柱状图是一种图形化工具,用于可视化数据中不同类别或组的分布情况。它通过绘制垂直条形来表示每个类别或组中的数据值。柱状图在信号处理中广泛用于可视化信号特征和进行频谱分析。 柱状图的优点在于其简单易懂,能够直观地展示数据分布。在信号处理中,柱状图可以帮助工程师识别信号中的模式、趋势和异常情况,从而为信号分析和处理提供有价值的见解。 # 2. 柱状图在信号处理中的应用 柱状图在信号处理
recommend-type

hive中 的Metastore

Hive中的Metastore是一个关键的组件,它用于存储和管理Hive中的元数据。这些元数据包括表名、列名、表的数据类型、分区信息、表的存储位置等信息。Hive的查询和分析都需要Metastore来管理和访问这些元数据。 Metastore可以使用不同的后端存储来存储元数据,例如MySQL、PostgreSQL、Oracle等关系型数据库,或者Hadoop分布式文件系统中的HDFS。Metastore还提供了API,使得开发人员可以通过编程方式访问元数据。 Metastore的另一个重要功能是跟踪表的版本和历史。当用户对表进行更改时,Metastore会记录这些更改,并且可以让用户回滚到
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。
recommend-type

"互动学习:行动中的多样性与论文攻读经历"

多样性她- 事实上SCI NCES你的时间表ECOLEDO C Tora SC和NCESPOUR l’Ingén学习互动,互动学习以行动为中心的强化学习学会互动,互动学习,以行动为中心的强化学习计算机科学博士论文于2021年9月28日在Villeneuve d'Asq公开支持马修·瑟林评审团主席法布里斯·勒菲弗尔阿维尼翁大学教授论文指导奥利维尔·皮耶昆谷歌研究教授:智囊团论文联合主任菲利普·普雷教授,大学。里尔/CRISTAL/因里亚报告员奥利维耶·西格德索邦大学报告员卢多维奇·德诺耶教授,Facebook /索邦大学审查员越南圣迈IMT Atlantic高级讲师邀请弗洛里安·斯特鲁布博士,Deepmind对于那些及时看到自己错误的人...3谢谢你首先,我要感谢我的两位博士生导师Olivier和Philippe。奥利维尔,"站在巨人的肩膀上"这句话对你来说完全有意义了。从科学上讲,你知道在这篇论文的(许多)错误中,你是我可以依
recommend-type

MATLAB柱状图在数据分析中的作用:从可视化到洞察

![MATLAB柱状图在数据分析中的作用:从可视化到洞察](https://img-blog.csdnimg.cn/img_convert/1a36558cefc0339f7836cca7680c0aef.png) # 1. MATLAB柱状图概述** 柱状图是一种广泛用于数据可视化的图表类型,它使用垂直条形来表示数据中不同类别或组别的值。在MATLAB中,柱状图通过`bar`函数创建,该函数接受数据向量或矩阵作为输入,并生成相应的高度条形。 柱状图的优点在于其简单性和易于理解性。它们可以快速有效地传达数据分布和组别之间的比较。此外,MATLAB提供了广泛的定制选项,允许用户调整条形颜色、
recommend-type

软件工程每个学期的生活及学习目标

软件工程每个学期的生活及学习目标可能包括以下内容: 1. 学习软件开发的基本理论和实践知识,掌握常用的编程语言和开发工具。 2. 熟悉软件开发的流程和方法,了解软件工程的标准和规范。 3. 掌握软件需求分析、设计、开发、测试、部署和维护的技能,能够独立完成简单的软件开发任务。 4. 培养团队合作的能力,学会与他人进行有效的沟通和协作,共同完成软件开发项目。 5. 提高自己的计算机技术水平,了解最新的软件开发技术和趋势,积极参与开源社区和技术交流活动。 6. 注重学习方法和习惯的培养,养成良好的学习和生活习惯,保持健康的身心状态。 7. 积极参加校内外的实践活动和比赛,拓展自己的视