没有合适的资源?快使用搜索试试~ 我知道了~
8-3 获取权限列表和角色权限(后端) - EMOS小程序 - 觅道文档MrDoc1
需积分: 0 0 下载量 147 浏览量
2022-08-04
15:05:03
上传
评论
收藏 233KB PDF 举报
温馨提示
试读
2页
2. …… 3. searchRoleOwnPermission: baseUrl + "/role/searchRoleOwnPermission" 4. }
资源详情
资源评论
资源推荐
8-3 获取权限列表和角色权限(后端)
140.143.132.225:8000/project-1/doc-141
一、封装URL地址
上节课我们把后端的Java代码写完了,可以向移动端返回权限列表数据。这节课我们要写移动端
的代码,发起Ajax请求,把获得的权限列表显示在页面上。
在 main.js 文件中定义Ajax请求的全局路径
1. Vue.prototype.url = {
2. ……
3. searchRoleOwnPermission: baseUrl + "/role/searchRoleOwnPermission"
4. }
二、编写回调函数
清空模型层静态数据,编写 onShow() 函数,加载动态数据。这里要注意模型层的 selected 是
JSON格式数据,KEY是权限ID,VALUE保存开关按钮的结果。
1. onShow: function() {
2. let that = this;
3. let url;
4. let method;
5. if (that.opt == 'insert') {
6. url = that.url.searchAllPermission;
7. method = 'GET';
8. } else {
9. url = that.url.searchRoleOwnPermission;
10. method = 'POST';
11. }
12. that.ajax(url,method,{"id":that.id},function(resp){
13. that.list = resp.data.result;
14. for (let one of that.list) {
15. for (let action of one.action) {
16. //把角色具有的权限保存到selected里面
17. if (action.selected == true) {
18. that.selected[action.id] = true;
19. }
20. }
21. }
22. })
23. }
编写 onLoad() 函数,获取URL参数,保存到模型层
Crazyanti
- 粉丝: 19
- 资源: 303
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0