Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
bkunyun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
bkunyun
Commits
ec1e6088
Commit
ec1e6088
authored
Oct 21, 2022
by
chenshouchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 完成cardtable
parent
48d91de2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
9 deletions
+106
-9
index.module.css
src/components/CommonComponents/CardTable/index.module.css
+7
-0
index.tsx
src/components/CommonComponents/CardTable/index.tsx
+41
-4
useMyRouter.ts
src/components/MyRouter/useMyRouter.ts
+0
-4
index.tsx
src/views/demo/CardTableDemo/index.tsx
+58
-1
No files found.
src/components/CommonComponents/CardTable/index.module.css
View file @
ec1e6088
.tableBox
{
display
:
flex
;
justify-content
:
flex-start
;
flex-wrap
:
wrap
;
}
.itemBox
{
}
src/components/CommonComponents/CardTable/index.tsx
View file @
ec1e6088
import
style
from
"./index.module.css"
;
import
style
from
"./index.module.css"
;
interface
ICardTableProps
{
interface
ICardTableProps
{
data
:
Array
<
any
>
;
data
:
Array
<
any
>
;
// 列表数据
renderItem
:
any
;
renderItem
:
any
;
// 单个卡片的渲染函数
tableKey
?:
string
;
// 表格数据的key
numberOfColumns
?:
number
;
// 列数 每行渲染几个
horizontalSpacing
?:
number
;
// 水平方向的间隔
verticalSpacing
?:
number
;
// 垂直方向的间隔
}
}
const
CardTable
=
(
props
:
ICardTableProps
)
=>
{
const
CardTable
=
(
props
:
ICardTableProps
)
=>
{
const
{
data
,
renderItem
}
=
props
;
const
{
return
<
div
>
CardTable
</
div
>;
data
,
renderItem
,
tableKey
=
"id"
,
numberOfColumns
=
3
,
horizontalSpacing
=
20
,
verticalSpacing
=
20
,
}
=
props
;
return
(
<
div
className=
{
style
.
tableBox
}
style=
{
{
marginLeft
:
`-${horizontalSpacing / 2}px`
,
marginRight
:
`-${horizontalSpacing / 2}px`
,
}
}
>
{
data
.
map
((
item
,
index
)
=>
{
return
(
<
div
className=
{
style
.
itemBox
}
key=
{
item
[
tableKey
]
?
item
[
tableKey
]
:
index
}
style=
{
{
width
:
`${100 / numberOfColumns}%`
,
paddingLeft
:
`${horizontalSpacing / 2}px`
,
paddingRight
:
`${horizontalSpacing / 2}px`
,
paddingBottom
:
`${verticalSpacing}px`
,
boxSizing
:
"border-box"
,
}
}
>
{
renderItem
(
item
,
index
)
}
</
div
>
);
})
}
</
div
>
);
};
};
export
default
CardTable
;
export
default
CardTable
;
src/components/MyRouter/useMyRouter.ts
View file @
ec1e6088
...
@@ -51,9 +51,6 @@ const useMyRouter = () => {
...
@@ -51,9 +51,6 @@ const useMyRouter = () => {
route
.
path
=
`
${
routeHead
}
/
${
item
.
id
}${
route
.
path
}
`
route
.
path
=
`
${
routeHead
}
/
${
item
.
id
}${
route
.
path
}
`
if
(
Array
.
isArray
(
route
.
children
))
{
if
(
Array
.
isArray
(
route
.
children
))
{
route
.
children
.
forEach
((
childrenItem
:
any
,
index
:
number
)
=>
{
route
.
children
.
forEach
((
childrenItem
:
any
,
index
:
number
)
=>
{
console
.
log
(
route
)
console
.
log
(
childrenItem
)
console
.
log
(
routeHead
)
if
(
childrenItem
.
path
)
{
if
(
childrenItem
.
path
)
{
childrenRoutes
.
push
({
childrenRoutes
.
push
({
...
childrenItem
,
...
childrenItem
,
...
@@ -63,7 +60,6 @@ const useMyRouter = () => {
...
@@ -63,7 +60,6 @@ const useMyRouter = () => {
})
})
}
}
})
})
// http://localhost:8088/v3/product/resourceCenter/userResources/seeEnv
route
.
children
=
route
.
children
.
filter
((
childrenItem
:
any
)
=>
!
childrenItem
.
path
)
route
.
children
=
route
.
children
.
filter
((
childrenItem
:
any
)
=>
!
childrenItem
.
path
)
}
}
}
}
...
...
src/views/demo/CardTableDemo/index.tsx
View file @
ec1e6088
import
CardTable
from
"@/components/CommonComponents/CardTable"
;
const
CardTableDemo
=
()
=>
{
const
CardTableDemo
=
()
=>
{
return
<
div
>
CardTableDemo
</
div
>;
const
list
=
[
{
id
:
1
,
},
{
id
:
2
,
},
{
id
:
3
,
},
{
id
:
4
,
},
{
id
:
5
,
},
{
id
:
6
,
},
{
id
:
7
,
},
{
id
:
8
,
},
{
id
:
9
,
},
{
id
:
10
,
},
{
id
:
11
,
},
{
id
:
12
,
},
{
id
:
13
,
},
];
const
renderItem
=
(
item
:
any
)
=>
{
return
(
<
div
style=
{
{
border
:
"1px solid red"
,
height
:
"200px"
}
}
>
{
item
.
id
}
</
div
>
);
};
return
(
<
div
>
CardTableDemo
<
CardTable
data=
{
list
}
renderItem=
{
renderItem
}
numberOfColumns=
{
4
}
></
CardTable
>
</
div
>
);
};
};
export
default
CardTableDemo
;
export
default
CardTableDemo
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment