fix: 纵向滚动条动态显示
This commit is contained in:
parent
06a0d594fd
commit
c0167c3ed2
|
@ -367,6 +367,10 @@ var Table = function (_Component) {
|
|||
if (nextProps.resetScroll) {
|
||||
this.resetScrollX();
|
||||
}
|
||||
// fix:模态框中使用table,计算的滚动条宽度为0的bug
|
||||
if (this.scrollbarWidth <= 0 && this.props.scroll.y) {
|
||||
this.scrollbarWidth = (0, _utils.measureScrollbar)();
|
||||
}
|
||||
|
||||
// console.log('this.scrollTop**********',this.scrollTop);
|
||||
};
|
||||
|
|
|
@ -74,6 +74,45 @@ const columns = [{
|
|||
render: renderContent,
|
||||
}];
|
||||
|
||||
|
||||
const columns1 = [{
|
||||
title: '姓名',
|
||||
key: "name",
|
||||
dataIndex: 'name',
|
||||
render: (text, row, index) => {
|
||||
if (index < 4) {
|
||||
return <a href="#">{text}</a>;
|
||||
}
|
||||
return {
|
||||
children: <a href="#">{text}</a>,
|
||||
props: {
|
||||
colSpan: 5,
|
||||
},
|
||||
};
|
||||
},
|
||||
}, {
|
||||
title: '年龄',
|
||||
key: "age",
|
||||
dataIndex: 'age',
|
||||
render: renderContent,
|
||||
}, {
|
||||
title: '联系方式',
|
||||
colSpan: 2,
|
||||
key: "tel",
|
||||
dataIndex: 'tel',
|
||||
render: renderContent
|
||||
}, {
|
||||
title: '手机号',
|
||||
colSpan: 0,
|
||||
key: "phone",
|
||||
dataIndex: 'phone',
|
||||
render: renderContent,
|
||||
}, {
|
||||
title: '家庭住址',
|
||||
key: "address",
|
||||
dataIndex: 'address',
|
||||
render: renderContent,
|
||||
}];
|
||||
const data = [{
|
||||
key: '1',
|
||||
name: '小红',
|
||||
|
@ -112,9 +151,26 @@ const data = [{
|
|||
}];
|
||||
|
||||
class Demo15 extends Component {
|
||||
constructor(props){
|
||||
super(props);
|
||||
this.state={
|
||||
colFlag:false
|
||||
}
|
||||
}
|
||||
onChange=()=>{
|
||||
const colFlag = this.state.colFlag;
|
||||
this.setState({
|
||||
colFlag:!colFlag
|
||||
})
|
||||
}
|
||||
render() {
|
||||
let cols = this.state.colFlag?columns:columns1;
|
||||
return (
|
||||
<Table columns={columns} data={data} bordered/>
|
||||
<div>
|
||||
<button onClick={this.onChange}>change列</button>
|
||||
<Table columns={cols} data={data} bordered/>
|
||||
</div>
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "bee-table",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25-beta.0",
|
||||
"description": "Table ui component for react",
|
||||
"keywords": [
|
||||
"react",
|
||||
|
|
|
@ -237,7 +237,7 @@ class Table extends Component {
|
|||
}
|
||||
|
||||
// 是否传入 scroll中的y属性,如果传入判断是否是整数,如果是则进行比较 。bodyTable 的clientHeight进行判断
|
||||
// this.isShowScrollY();
|
||||
this.isShowScrollY();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
@ -313,7 +313,7 @@ class Table extends Component {
|
|||
const bodyH = this.bodyTable.clientHeight;
|
||||
const bodyContentH = this.bodyTable.querySelector('table').clientHeight;
|
||||
const rightBodyTable = this.refs.fixedColumnsBodyRight;
|
||||
const leftBodyTable = this.refs.fixedColumnsBodyLeft;
|
||||
// const leftBodyTable = this.refs.fixedColumnsBodyLeft;
|
||||
const overflowy = bodyContentH <= bodyH ? 'auto':'scroll';
|
||||
this.bodyTable.style.overflowY = overflowy;
|
||||
|
||||
|
|
Loading…
Reference in New Issue