当前位置:网站首页>基於JEECG-BOOT的list頁面的地址欄參數傳遞
基於JEECG-BOOT的list頁面的地址欄參數傳遞
2022-07-06 06:25: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頁面中編寫代碼即可。
边栏推荐
- The pit encountered by keil over the years
- E - food chain
- Simulation volume leetcode [general] 1296 Divide an array into a set of consecutive numbers
- 黑猫带你学UFS协议第8篇:UFS初始化详解(Boot Operation)
- G - Supermarket
- sourceInsight中文乱码
- mysql按照首字母排序
- PHP uses redis to implement distributed locks
- Selenium source code read through · 9 | desiredcapabilities class analysis
- [no app push general test plan
猜你喜欢

JDBC Requset 对应内容及功能介绍

Pat (Grade B) 2022 summer exam

基于JEECG-BOOT的list页面的地址栏参数传递

Avtiviti创建表时报错:Error getting a new connection. Cause: org.apache.commons.dbcp.SQLNestedException

G - Supermarket

B - The Suspects

Remember the implementation of a relatively complex addition, deletion and modification function based on jeecg-boot

sourceInsight中文乱码

私人云盘部署

曼哈顿距离与曼哈顿矩形-打印回字型矩阵
随机推荐
Isam2 and incrementalfixedlagsmooth instructions in gtsam
模拟卷Leetcode【普通】1219. 黄金矿工
MySQL之数据类型
Remember the implementation of a relatively complex addition, deletion and modification function based on jeecg-boot
Online and offline problems
模拟卷Leetcode【普通】1109. 航班预订统计
【Tera Term】黑猫带你学TTL脚本——嵌入式开发中串口自动化神技能
Manhattan distance and Manhattan rectangle - print back font matrix
Oscp raven2 target penetration process
使用Nacos管理配置
Réflexions sur la sécurité des données (réimpression)
JMeter做接口测试,如何提取登录Cookie
模拟卷Leetcode【普通】1405. 最长快乐字符串
[no app push general test plan
On weak network test of special test
Avtiviti创建表时报错:Error getting a new connection. Cause: org.apache.commons.dbcp.SQLNestedException
Data type of MySQL
Testing of web interface elements
JDBC Requset 对应内容及功能介绍
B - The Suspects