Skip to content

Commit 804a67b

Browse files
committed
fix 因为layout布局的content造成的子元素高度100%在360浏览器中造成的不兼容问题
---解决办法:不使用antd的layout布局中的content,使用div+calc函数来计算content内容的高度
1 parent 63172a0 commit 804a67b

File tree

8 files changed

+35
-25
lines changed

8 files changed

+35
-25
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width,initial-scale=1.0">
6+
<meta name="renderer" content="webkit">
67
<link rel="icon" href="/static/img/favicon.png" type="image/x-icon">
78
<title>权限管理脚手架</title>
89
</head>

src/components/m-table/m-table.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
@close="handleCreateDrawClose"></m-create>
1111
<m-edit :visible="showEditDrawer" :options="options.operation ? options.operation.edit : {}"
1212
:record="editRecord" @close="handleEditDrawClose"></m-edit>
13-
<a-table :columns="columns" :rowKey="rowKey" :style="options.attribute.tableStyle" :ref="options.id"
13+
<a-table :columns="columns" :rowKey="rowKey" :style="options.attribute.tableStyle" :class="options.id"
1414
:dataSource="dataList" :pagination="pagination"
1515
:size="options.attribute.size" :bordered="options.attribute.bordered"
1616
:scroll="finalScroll"
@@ -127,17 +127,17 @@
127127
// 监听window的resize方法,并加入防抖函数
128128
window.addEventListener('resize', window.$debounce(() => {
129129
this.setTableScroll();
130-
console.log(this)
131130
}, 200)
132131
, false)
133132
},
134133
methods: {
135134
// 设置table的默认Scroll
136135
setTableScroll() {
137-
let tableTop = this.$refs[this.options.id].$el.offsetTop // table距离文档顶端距离
136+
let tableTop = document.querySelector(`.${this.options.id}`).offsetTop // table距离文档顶端距离
138137
let viewTop = document.querySelector('.view-template-wrap').offsetTop // router-view距离文档顶端距离
139138
let viewHeight = document.querySelector('.view-template-wrap').clientHeight // router-view高度
140139
this.scroll = {
140+
x : true,
141141
y : viewHeight - (tableTop - viewTop) - 54 - 65 // 减去的54为table的header高度,64为pagination高度
142142
}
143143
},

src/components/m-test/m-test.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
22
<div class="test-wrap">
3+
<div class="test-child">123</div>
34
</div>
45
</template>
56

@@ -84,6 +85,18 @@
8485
}
8586
</script>
8687

87-
<style scoped>
88+
<style scoped lang="less">
89+
.test-wrap{
90+
width: 200px;
91+
height: 300px;
92+
.test-child{
93+
width: 100%;
94+
height: 100%;
95+
display: flex;
96+
align-items: center;
97+
justify-content: center;
98+
background: tomato;
99+
}
100+
}
88101
89102
</style>

src/pages/index/index.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
}
2929
.index-content-wrap {
3030
margin: 15px 10px;
31+
height: calc(100% - 64px);
3132
//padding: 10px;
3233
background: #fff;
33-
minHeight: 280px;
3434
overflow: auto;
3535
}
3636
}

src/pages/index/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
<a-layout>
1717
<m-header :collapsed="collapsed" @clickCollBtn="()=> collapsed = !collapsed"></m-header>
1818

19-
<a-layout-content class="index-content-wrap">
19+
<div class="index-content-wrap">
2020
<router-view></router-view>
21-
</a-layout-content>
21+
</div>
2222
</a-layout>
2323
</a-layout>
2424
</template>

src/pages/system/sys-user/sys-user-table/sys-user-table.vue

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<a-table :columns="columns" :rowKey="record => record.record_id"
44
:pagination="pagination" size="middle"
55
:dataSource="data" :loading="loading" @change="handleTableChange"
6-
:scroll="scroll" ref="table">
6+
:scroll="scroll" class="sys-user-table">
77
<template slot="roles" slot-scope="text, record">
88
<span v-for="(item, index) in text" :key="index"> {{item.name}}</span>
99
</template>
@@ -85,13 +85,13 @@
8585
title: '用户名',
8686
dataIndex: 'user_name',
8787
align: 'center',
88-
width: '200px'
88+
width: '180px',
8989
},
9090
{
9191
title: '真实姓名',
9292
dataIndex: 'real_name',
9393
align: 'center',
94-
width: '200px',
94+
width: '150px',
9595
},
9696
{
9797
title: '角色名称',
@@ -104,7 +104,7 @@
104104
title: '用户状态',
105105
dataIndex: 'status',
106106
align: 'center',
107-
width: '200px',
107+
width: '90px',
108108
scopedSlots: {customRender: 'status'}
109109
},
110110
{
@@ -117,14 +117,7 @@
117117
title: '手机号',
118118
dataIndex: 'phone',
119119
align: 'center',
120-
width: '200px',
121-
},
122-
{
123-
title: '创建时间',
124-
dataIndex: 'created_at',
125-
align: 'center',
126-
width: '220px',
127-
scopedSlots: {customRender: 'created'},
120+
width: '130px',
128121
},
129122
{
130123
title: '操作',
@@ -142,23 +135,25 @@
142135
// 监听window的resize方法,并加入防抖函数
143136
window.addEventListener('resize', window.$debounce(() => {
144137
this.setTableScroll();
145-
console.log(this)
146138
}, 200)
147139
, false)
148140
},
149141
methods: {
150142
// 设置table的默认Scroll
151143
setTableScroll() {
152144
setTimeout(() => {
153-
let tableTop = this.$refs.table.$el.offsetTop // table距离文档顶端距离
145+
let tableTop = document.querySelector('.sys-user-table').offsetTop // table距离文档顶端距离
154146
let viewTop = document.querySelector('.router-wrap').offsetTop // router-view距离文档顶端距离
155147
let viewHeight = document.querySelector('.router-wrap').clientHeight // router-view高度
156-
console.log(this.$refs.table.$el, tableTop)
148+
console.log(document.querySelector('.sys-user-table'), tableTop)
157149
console.log(document.querySelector('.router-wrap'), viewTop, viewHeight)
150+
let scrollY = viewHeight - (tableTop - viewTop) - 45 - 60 // 减去的45为table的header高度, 60为pagination高度
151+
console.log(scrollY)
158152
this.scroll = {
159-
y : viewHeight - (tableTop - viewTop) - 45 - 60 // 减去的45为table的header高度, 60为pagination高度
153+
x: true,
154+
y : scrollY
160155
}
161-
}, 10)
156+
}, 50)
162157
163158
},
164159
onEnable (record_id) {

src/pages/view-template/test-data/query-table布局.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export default [
111111
bordered: false,
112112
size : 'default',
113113
showHeader: true,
114+
// 不传自响应
114115
// scroll:{ // table scroll
115116
// x: 300,
116117
// y: 100

src/server/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ axios.interceptors.response.use(data=> {
3939
return data;
4040
}, err=> {
4141
// console.error('响应拦截器', err.response.status)
42-
if(err.response.status == 401){
42+
if(err.response.status == 401 || err.response.status == 400){
4343
Message.error(err.response.data.error.message);
4444
let hash = location.hash.split('?')[0];
4545
let path = hash.slice(1, hash.length);

0 commit comments

Comments
 (0)