Match-id-af5f4471321b0cdce3f5343e1c2f451887b30c17

This commit is contained in:
* 2022-03-23 11:08:28 +08:00 committed by *
parent dec773daef
commit 5f042d8fa8
3 changed files with 35 additions and 20 deletions

View File

@ -0,0 +1,10 @@
.tree_container {
position: absolute;
width: 100%;
height: 100%;
overflow-y: auto;
}
.tree_item{
width: 100%;
}

View File

@ -1,4 +1,5 @@
import { useState } from 'horizon'; import { useState } from 'horizon';
import styles from './VTree.less';
export interface IData { export interface IData {
id: string; id: string;
@ -24,7 +25,7 @@ function Item({ name, style, userKey, hasChild, onExpand, id, indentation }: IIt
onExpand(id); onExpand(id);
} }
return ( return (
<div style={style}> <div style={style} className={styles.tree_item}>
<div style={{ display: 'inline-block', marginLeft: indentation * 20, width: 10 }} onClick={onClickExpand} >{showIcon}</div> <div style={{ display: 'inline-block', marginLeft: indentation * 20, width: 10 }} onClick={onClickExpand} >{showIcon}</div>
{name + key} {name + key}
</div> </div>
@ -72,7 +73,6 @@ function VTree({ data }: { data: IData[] }) {
style={{ style={{
position: 'absolute', position: 'absolute',
transform: `translateY(${totalHeight}px)`, transform: `translateY(${totalHeight}px)`,
width: '100%'
}} }}
onExpand={changeExpandNode} onExpand={changeExpandNode}
{...item} /> {...item} />
@ -92,7 +92,7 @@ function VTree({ data }: { data: IData[] }) {
} }
return ( return (
<div style={{ position: 'absolute', width: '100%', height: '100%', overflowY: 'auto' }} onScroll={scroll}> <div className={styles.tree_container} onScroll={scroll}>
{showList} {showList}
{/* 确保有足够的高度 */} {/* 确保有足够的高度 */}
<div style={{ marginTop: totalHeight }} /> <div style={{ marginTop: totalHeight }} />

View File

@ -16,24 +16,29 @@ module.exports = {
extensions: ['.ts', '.tsx', '.js'] extensions: ['.ts', '.tsx', '.js']
}, },
module: { module: {
rules: [{ rules: [
test: /\.tsx?$/, {
exclude: /node_modules/, test: /\.tsx?$/,
use: [ exclude: /node_modules/,
{ use: [
loader: 'babel-loader', {
options: { loader: 'babel-loader',
presets: ['@babel/preset-env', options: {
'@babel/preset-typescript', presets: ['@babel/preset-env',
['@babel/preset-react', { '@babel/preset-typescript',
runtime: 'classic', ['@babel/preset-react', {
"pragma": "Horizon.createElement", runtime: 'classic',
"pragmaFrag": "Horizon.Fragment", "pragma": "Horizon.createElement",
}]], "pragmaFrag": "Horizon.Fragment",
}]],
}
} }
} ]
] },
}] {
test: /\.less/i,
use: ["style-loader", { loader: "css-loader", options: { modules: true } }, 'less-loader'],
}]
}, },
externals: { externals: {
'horizon': 'Horizon', 'horizon': 'Horizon',