当前位置:网站首页>基于JEECG-BOOT的list页面的地址栏参数传递
基于JEECG-BOOT的list页面的地址栏参数传递
2022-07-06 06:19:00 【瀚岳-诸葛弩】
前置知识:
1、什么是地址栏参数传递?地址栏参数传递的格式是什么(?变量1=值1&变量2=值2……)
2、如果通过JavaScript获取地址栏参数(网上有各种解决方案)
我的方法(放到util.js里):
export function getUrlParam(name){
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r!=null) return decodeURI(r[2]); return '';
}3、对jeecg的mixin的了解(看代码,看开发文档)
主要实现:
1、构建通用的地址栏参数获取方法
因为地址栏参数获取是非常常用的方法,所以在网上找到js地址栏参数获取解决方案后,可将其添加到jeecg-boot的:src/utils/util.js中
/**
* 从地址栏获取指定参数
* @param {*} name
*/
export function getUrlParam(name){
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r!=null) return decodeURI(r[2]); return '';
}2、JEECG-BOOT中代码的理解
关键:src/mixins/JeecgListMixin.js
(1)混入覆盖:这个mixin.js是jeecg为了简化前端操作,将很多通用代码进行了包装。同时,jeecg-boot也为我们提供了可以混入的接口,

上图中的disableMixinCreated就是这个混入覆盖的判断变量
(2)条件生成

上图中的queryParam就是根据实体要构建的过滤条件,上图的方法在loadData(arg)中被调用,如下:

(3)数据获取
Jeecg-boot对axios进行了进一步封装,这里是getAction,还有个postAction等,分别执行不同类型的请求,在使用过程中直接调用就好,具体代码在:src/api/manage.js(这里不详述,因为不用去修改)

getAction,postActon等是我们在编写代码时经常要用到的,所以此处可以看下jeecg的官方调用代码,方便后续自行模拟编写。
3、list页面的代码编写
明白第2步的原理后,在第1步的基础上我们就可以非常简单地实现list页面参数的传递与配置:
(1)在list页面的data部分设置:disableMixinCreated:true

(2)在created部分获取参数,并调用mixin代码

注意:(1)如果在list页面不配置disableMixinCreated:true,那么代码将不会混入覆盖,list请求将被加载两次。
(2)如果第2步看不明白,没关系,就先将第1步的代码放到util.js中,然后按照第3步方法直接在list页面中编写代码即可。
边栏推荐
- F - true liars (category and search set +dp)
- Simulation volume leetcode [general] 1414 The minimum number of Fibonacci numbers with a sum of K
- 模拟卷Leetcode【普通】1062. 最长重复子串
- [C language] string left rotation
- 使用Nacos管理配置
- D - How Many Answers Are Wrong
- Manhattan distance sum - print diamond
- P问题、NP问题、NPC问题、NP-hard问题详解
- Play video with Tencent video plug-in in uni app
- The latest 2022 review of "graph classification research"
猜你喜欢

keil MDK中删除添加到watch1中的变量

【eolink】PC客户端安装

How to extract login cookies when JMeter performs interface testing

【MQTT从入门到提高系列 | 01】从0到1快速搭建MQTT测试环境

ICLR 2022 spotlight | analog transformer: time series anomaly detection method based on correlation difference
![[API interface tool] Introduction to postman interface](/img/03/c1541fca65dd726fd4bdc8793b605e.png)
[API interface tool] Introduction to postman interface

职场进阶指南:大厂人必看书籍推荐

数据库-当前读与快照读

P问题、NP问题、NPC问题、NP-hard问题详解

ESP32 ESP-IDF看门狗TWDT
随机推荐
Simulation volume leetcode [general] 1061 Arrange the smallest equivalent strings in dictionary order
模拟卷Leetcode【普通】1447. 最简分数
Delete the variables added to watch1 in keil MDK
How to extract login cookies when JMeter performs interface testing
Simulation volume leetcode [general] 1218 Longest definite difference subsequence
php使用redis实现分布式锁
The pit encountered by keil over the years
模拟卷Leetcode【普通】1296. 划分数组为连续数字的集合
Fault, error, failure of functional safety
【Postman】Collections配置运行过程
「 WEB测试工程师 」岗位一面总结
Selenium source code read through · 9 | desiredcapabilities class analysis
Coordinatorlayout+nestedscrollview+recyclerview pull up the bottom display is incomplete
MySQL之数据类型
selenium源码通读·9 |DesiredCapabilities类分析
The latest 2022 review of "graph classification research"
【Postman】测试(Tests)脚本编写和断言详解
Postman核心功能解析-参数化和测试报告
Simulation volume leetcode [general] 1405 Longest happy string
把el-tree选中的数组转换为数组对象