当前位置: 首页 > news >正文

企业网站建设的账务处理百度网站优化培训

企业网站建设的账务处理,百度网站优化培训,网络设计一般不考虑,网站建设费用没有发票怎样入账使用vue实现分页的逻辑并不复杂,接收后端传输过来的数据,然后根据数据的总数和每一页的数据量就可以计算出一共可以分成几页 我编写了一个简单的前端页面用来查询数据,页面一共有几个逻辑 具体的效果可以看下面的演示 下面就来看一下具体的实…

使用vue实现分页的逻辑并不复杂,接收后端传输过来的数据,然后根据数据的总数和每一页的数据量就可以计算出一共可以分成几页

我编写了一个简单的前端页面用来查询数据,页面一共有几个逻辑

 

 具体的效果可以看下面的演示

 

 

下面就来看一下具体的实现步骤。

首先看一下vue的代码

<script type="text/javascript">Vue.createApp({data()  {return {items : [],// 关键词keyword : "",// 是否没有数据isnull : false,// 一开始不显示上一页和下一页isshow : false,// 一共有多少条数据countInfo : 0,// 每一页显示几条数据pageSize : 10,// 当前是第几页currentPage : 1,// 一共有几页countAll : 1,code : 200}},methods: {search() {// 拿到待搜索的关键词var keyword = document.getElementById("keyword").value;console.log(keyword);this.keyword = keyword;this.currentPage = 1;var url = "http://localhost:8080/csdn/search/" + keyword + "/" + this.currentPage;console.log(url);axios.get(url).then((response) => {if(response.data.msg.count==0) {this.isnull = true;// 将原始数据置空this.items = [];// 不显示上一页下一页按钮this.isshow = false;} else {this.isnull = false;console.log(response)this.items = response.data.msg.list;this.countInfo = response.data.msg.count;// 计算一共有几页this.countAll = Math.ceil(response.data.msg.count / this.pageSize); this.isshow = true;}}).catch(function (error) {console.log(error);});},getNextPage() {if(this.currentPage == this.countAll) {this.currentPage = this.currentPage;} else {this.currentPage = this.currentPage + 1;}var url = "http://localhost:8080/csdn/search/" + this.keyword + "/" + this.currentPage;axios.get(url).then((response) => {console.log(response)this.items = response.data.msg.list;// 计算一共有几页this.countAll = Math.ceil(response.data.msg.count / this.pageSize); }).catch(function (error) {console.log(error);});},getPrePage() {if(this.currentPage == 1) {this.currentPage = 1;} else {this.currentPage = this.currentPage - 1;}var url = "http://localhost:8080/csdn/search/" + this.keyword + "/" + this.currentPage;axios.get(url).then((response) => {console.log(response)this.items = response.data.msg.list;// 计算一共有几页this.countAll = Math.ceil(response.data.msg.count / this.pageSize); }).catch(function (error) {console.log(error);});}},}).mount("#app");
</script>

 data()中返回了几个变量,

  • items:用来存放待展示的数据项
  • keyword:记录本次查询使用的关键词

  • isnull:表示一次查询的结果数量是否为0,用来控制没有结果的显示逻辑

  • isshow:表示是否显示上一页下一页按钮,以及显示当前页数和数据总数

  • countInfo:记录一共有多少条结果

  • pageSize:记录每页显示的数据项,目前后端固定每页展示10条数据

  • currentPage:记录当前是第几页

  • countAll:记录一共有多少页数据

  • code:后端返回的一个状态码,没什么用

一共提供了三个方法进行查询

  • search():进行一个新的关键词的查询
  • getNextPage():查询下一页的数据,如果已经是最后一页了,则查询当前页的结果
  • getPrePage():查询上一页的数据,如果已经是第一页了,则查询当前页的结果

接着我们再来看一下后端返回的数据格式

上图中方框内的数据就是后端返回的数据,msg中记录的就是我们需要用到的数据,里面有交给数据项

  • count:表示数据总数,只是查询数据总数,并不会将所有的数据都返回给前端
  • list:返回当前页的数据
  • page:表示当前是第几页 

 我们具体来看一下list中数据项的内容

可以发现list中的每一项就是构成我们前端页面中一行的数据,这在vue中体现为数据的绑定,下面就来看看详细的html代码

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<html lang="en">
<head><meta charset="UTF-8"><title>纳米搜索</title><link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css"><script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script><script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script><script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script><script src="https://unpkg.com/vue@3"></script><script src="https://unpkg.com/axios/dist/axios.min.js"></script></head>
<body><div class="container"><!-- 先编写一个搜索栏 --><div class="row" id="app"><div class="col-md-1"></div><div class="col-md-10"><!-- 这里面有两个个部分 --><div class="row"><!--<div class="col-md-2"></div>--><div class="col-md-12"><div style="float: left; margin-top: 20px;margin-left: 20%"><h2 style="color:cornflowerblue">纳米搜索</h2></div><div style="float: left; margin-top: 20px; margin-left: 20px"><div class="form-group" style="margin-right: 20px; float: left;" ><div class="input-group" ><input type="text" class="form-control" name="keyword"  id="keyword" placeholder="请输入要搜索的关键词"></div></div><div style="float:left"><button id="search" type="button" class="btn btn-primary" v-on:click="search">搜索</button></div></div></div><!--<div class="col-md-2"></div>--></div><hr><div><div v-for="item of items"><!-- 第一行是url --><a :href="item.url" target="_blank"><div style="color: #0000cc">{{item.title}}</div></a><div style="color: #28a745">{{item.url}}</div><!-- 这一行显示文章作者 --><div style="color: #000000">文章作者:<span style="color: #000000; margin-left: 10px">{{item.nick_name}}</span></div><!-- 这一行显示标签 --><div style="color: #000000">文章标签:<span style="color: #000000; margin-left: 10px">{{item.tag}}</span></div><!-- 下面一行显示发表时间,阅读数和收藏数 --><div><div style="color: #000000">发表时间:<span style="color: #000000;margin-left: 10px">{{item.up_time}}</span></div><div style="color: #000000;float: left">阅读量:<span style="color: #000000;margin-left: 10px">{{item.read_volum}}</span></div><div style="color: #000000;float: left; margin-left: 10px">收藏量:<span style="color: #000000;margin-left: 10px">{{item.collection_volum}}</span></div></div><br><hr></div></div><!-- 当没有查询结果的时候显示 --><div v-if="isnull"><span>非常抱歉,没有您想要的结果(。・_・。)ノI’m sorry~</span></div><!-- 当有数据的时候显示 --><div v-if="isshow"><div style="float:left; margin-right: 20px;" ><button type="button" class="btn btn-primary" v-on:click="getPrePage">上一页</button></div><div style="float:left; margin-right: 20px;" ><button type="button" class="btn btn-primary" v-on:click="getNextPage" >下一页</button></div><div style="float:left; margin-right: 20px; margin-top: 5px;"><span>第{{currentPage}}/{{countAll}}页</spa></div><div style="float:left; margin-right: 20px; margin-top: 5px;"><span>共有{{countInfo}}条数据</spa></div></div></div><div class="col-md-1"></div></div></div>
</body>
<script type="text/javascript">Vue.createApp({data()  {return {items : [],// 关键词keyword : "",// 是否没有数据isnull : false,// 一开始不显示上一页和下一页isshow : false,// 一共有多少条数据countInfo : 0,// 每一页显示几条数据pageSize : 10,// 当前是第几页currentPage : 1,// 一共有几页countAll : 1,code : 200}},methods: {search() {// 拿到待搜索的关键词var keyword = document.getElementById("keyword").value;console.log(keyword);this.keyword = keyword;this.currentPage = 1;var url = "http://localhost:8080/csdn/search/" + keyword + "/" + this.currentPage;console.log(url);axios.get(url).then((response) => {if(response.data.msg.count==0) {this.isnull = true;// 将原始数据置空this.items = [];// 不显示上一页下一页按钮this.isshow = false;} else {this.isnull = false;console.log(response)this.items = response.data.msg.list;this.countInfo = response.data.msg.count;// 计算一共有几页this.countAll = Math.ceil(response.data.msg.count / this.pageSize); this.isshow = true;}}).catch(function (error) {console.log(error);});},getNextPage() {if(this.currentPage == this.countAll) {this.currentPage = this.currentPage;} else {this.currentPage = this.currentPage + 1;}var url = "http://localhost:8080/csdn/search/" + this.keyword + "/" + this.currentPage;axios.get(url).then((response) => {console.log(response)this.items = response.data.msg.list;// 计算一共有几页this.countAll = Math.ceil(response.data.msg.count / this.pageSize); }).catch(function (error) {console.log(error);});},getPrePage() {if(this.currentPage == 1) {this.currentPage = 1;} else {this.currentPage = this.currentPage - 1;}var url = "http://localhost:8080/csdn/search/" + this.keyword + "/" + this.currentPage;axios.get(url).then((response) => {console.log(response)this.items = response.data.msg.list;// 计算一共有几页this.countAll = Math.ceil(response.data.msg.count / this.pageSize); }).catch(function (error) {console.log(error);});}},}).mount("#app");
</script></html>

使用vue编写前端动态页面真的比原生js或者jquery要方便很多,对比theamleaf也有很多好处。

我们在使用theamleaf的时候,每次提交表单都需要刷新页面,使用vue+axios进行ajax请求则不需要刷新页面,这不仅会减轻服务端的压力,而且可以带来更好的用户体验。


文章转载自:
http://www.morning.dnqpq.cn.gov.cn.dnqpq.cn
http://www.morning.phwmj.cn.gov.cn.phwmj.cn
http://www.morning.kgltb.cn.gov.cn.kgltb.cn
http://www.morning.wqwbj.cn.gov.cn.wqwbj.cn
http://www.morning.rrgm.cn.gov.cn.rrgm.cn
http://www.morning.rqrxh.cn.gov.cn.rqrxh.cn
http://www.morning.mlcwl.cn.gov.cn.mlcwl.cn
http://www.morning.hkchp.cn.gov.cn.hkchp.cn
http://www.morning.xyrw.cn.gov.cn.xyrw.cn
http://www.morning.jqpq.cn.gov.cn.jqpq.cn
http://www.morning.kqblk.cn.gov.cn.kqblk.cn
http://www.morning.tsnmt.cn.gov.cn.tsnmt.cn
http://www.morning.yxkyl.cn.gov.cn.yxkyl.cn
http://www.morning.rwmp.cn.gov.cn.rwmp.cn
http://www.morning.rmyt.cn.gov.cn.rmyt.cn
http://www.morning.hkpn.cn.gov.cn.hkpn.cn
http://www.morning.lqgfm.cn.gov.cn.lqgfm.cn
http://www.morning.tqbyw.cn.gov.cn.tqbyw.cn
http://www.morning.xbdrc.cn.gov.cn.xbdrc.cn
http://www.morning.nqpy.cn.gov.cn.nqpy.cn
http://www.morning.wxfjx.cn.gov.cn.wxfjx.cn
http://www.morning.qhmhz.cn.gov.cn.qhmhz.cn
http://www.morning.pqqxc.cn.gov.cn.pqqxc.cn
http://www.morning.ljdhj.cn.gov.cn.ljdhj.cn
http://www.morning.lskyz.cn.gov.cn.lskyz.cn
http://www.morning.xnkb.cn.gov.cn.xnkb.cn
http://www.morning.qyjqj.cn.gov.cn.qyjqj.cn
http://www.morning.pndhh.cn.gov.cn.pndhh.cn
http://www.morning.rwrn.cn.gov.cn.rwrn.cn
http://www.morning.nkpml.cn.gov.cn.nkpml.cn
http://www.morning.spdyl.cn.gov.cn.spdyl.cn
http://www.morning.kyctc.cn.gov.cn.kyctc.cn
http://www.morning.kphsp.cn.gov.cn.kphsp.cn
http://www.morning.c-ae.cn.gov.cn.c-ae.cn
http://www.morning.jnrry.cn.gov.cn.jnrry.cn
http://www.morning.mqxrx.cn.gov.cn.mqxrx.cn
http://www.morning.jxdhc.cn.gov.cn.jxdhc.cn
http://www.morning.qxmpp.cn.gov.cn.qxmpp.cn
http://www.morning.dhbyj.cn.gov.cn.dhbyj.cn
http://www.morning.ltpmy.cn.gov.cn.ltpmy.cn
http://www.morning.lnbcx.cn.gov.cn.lnbcx.cn
http://www.morning.jbgzy.cn.gov.cn.jbgzy.cn
http://www.morning.dkcpt.cn.gov.cn.dkcpt.cn
http://www.morning.lfjmp.cn.gov.cn.lfjmp.cn
http://www.morning.qdrrh.cn.gov.cn.qdrrh.cn
http://www.morning.kbntl.cn.gov.cn.kbntl.cn
http://www.morning.fnzbx.cn.gov.cn.fnzbx.cn
http://www.morning.xxwhz.cn.gov.cn.xxwhz.cn
http://www.morning.rmtxp.cn.gov.cn.rmtxp.cn
http://www.morning.wsxxq.cn.gov.cn.wsxxq.cn
http://www.morning.hnrdtz.com.gov.cn.hnrdtz.com
http://www.morning.blxlf.cn.gov.cn.blxlf.cn
http://www.morning.nqpxs.cn.gov.cn.nqpxs.cn
http://www.morning.zcqtr.cn.gov.cn.zcqtr.cn
http://www.morning.rfbpq.cn.gov.cn.rfbpq.cn
http://www.morning.psxwc.cn.gov.cn.psxwc.cn
http://www.morning.bpxmw.cn.gov.cn.bpxmw.cn
http://www.morning.lqgtx.cn.gov.cn.lqgtx.cn
http://www.morning.fyglg.cn.gov.cn.fyglg.cn
http://www.morning.rmkyb.cn.gov.cn.rmkyb.cn
http://www.morning.jwbnm.cn.gov.cn.jwbnm.cn
http://www.morning.gynlc.cn.gov.cn.gynlc.cn
http://www.morning.kgnnc.cn.gov.cn.kgnnc.cn
http://www.morning.trhlb.cn.gov.cn.trhlb.cn
http://www.morning.lkfhk.cn.gov.cn.lkfhk.cn
http://www.morning.ghrlx.cn.gov.cn.ghrlx.cn
http://www.morning.ygwbg.cn.gov.cn.ygwbg.cn
http://www.morning.rgyts.cn.gov.cn.rgyts.cn
http://www.morning.mtrz.cn.gov.cn.mtrz.cn
http://www.morning.wsnjn.cn.gov.cn.wsnjn.cn
http://www.morning.rfpb.cn.gov.cn.rfpb.cn
http://www.morning.mllmm.cn.gov.cn.mllmm.cn
http://www.morning.jtcq.cn.gov.cn.jtcq.cn
http://www.morning.xsbhg.cn.gov.cn.xsbhg.cn
http://www.morning.muzishu.com.gov.cn.muzishu.com
http://www.morning.jggr.cn.gov.cn.jggr.cn
http://www.morning.wdxr.cn.gov.cn.wdxr.cn
http://www.morning.jkwwm.cn.gov.cn.jkwwm.cn
http://www.morning.qbtj.cn.gov.cn.qbtj.cn
http://www.morning.ckrnq.cn.gov.cn.ckrnq.cn
http://www.tj-hxxt.cn/news/14035.html

相关文章:

  • 高端网站建设上惠州seo管理
  • 网站开发取名东莞搜索引擎推广
  • 天水有做网站的地方吗百度长尾关键词挖掘工具
  • 二个字最吉利最旺财的公司名推推蛙seo顾问
  • 深圳建站公司的小技巧seo和点击付费的区别
  • 大流量网站开发广州seo推广公司
  • seo前线seo代运营
  • 刷qq会员自己做网站怎么做一个免费的网站
  • 温州做网站建设站长之家音效素材
  • 没有后台的网站怎么做排名京津冀协同发展
  • com域名和网站网络广告的计费方式
  • seo企业网站优化网站域名查询地址
  • 江门找做公众号的网站小广告网站
  • 如何创建本地站点php视频转码
  • 美食网页设计论文兰州网络seo
  • 泸州市建设厅官方网站长春网站排名提升
  • 添加qq好友的超链接做网站国内真正的永久免费砖石
  • 论坛网站怎么做排名网站seo优化方法
  • 创意餐厅网站建设文案书百度推广一年收费标准
  • 重庆域名注册官网沈阳seo关键词排名
  • 做网站 郑州公司近几天发生的新闻大事
  • 网站中有一个非常著名的原则windows优化大师有哪些功能
  • 网站的尾页要怎么做江西百度推广公司
  • 网站建设 合优网络如何利用网络进行推广和宣传
  • wordpress职业学校模板seo关键词排名优化矩阵系统
  • 建筑方案设计考试济南seo优化公司助力排名
  • 钢材销售都在哪个网站做软文发布的平台与板块
  • 拼多多电商网站建设免费刷粉网站推广
  • 盐城seo快速排名百度seo优化按年收费
  • 中小学智慧校园建设平台网站登封seo公司