liujiangyong
1 year ago
3 changed files with 80 additions and 1 deletions
@ -0,0 +1,35 @@ |
|||
/* |
|||
* 骨架屏 |
|||
*/ |
|||
import React from 'react' |
|||
import { View } from '@tarojs/components' |
|||
import './index.scss' |
|||
|
|||
export default function Skeleton(props) { |
|||
const { length } = props |
|||
|
|||
const render = () => { |
|||
let node = [] |
|||
for (let i = 0; i < length; i++) { |
|||
node.push( |
|||
<View className='skeleton'> |
|||
<View className='ul'> |
|||
<View className='li' /> |
|||
<View className='li' /> |
|||
<View className='li' /> |
|||
<View className='li' /> |
|||
<View className='li' /> |
|||
<View className='li' /> |
|||
</View> |
|||
</View> |
|||
) |
|||
} |
|||
return node |
|||
} |
|||
|
|||
return ( |
|||
<View> |
|||
{render()} |
|||
</View> |
|||
) |
|||
} |
@ -0,0 +1,43 @@ |
|||
.screen-root { |
|||
width: 100%; |
|||
height: 100%; |
|||
display: flex; |
|||
justify-content: center; |
|||
margin-top: 20vh; |
|||
} |
|||
|
|||
.ul { |
|||
background-color: #fff; |
|||
margin: 0 auto; |
|||
padding: 20px; |
|||
width: 90vw; |
|||
} |
|||
|
|||
.li { |
|||
background-image: linear-gradient(90deg, #f2f2f2 25%, #e6e6e6 37%, #f2f2f2 63%); |
|||
width: 100%; |
|||
height: 0.9rem; |
|||
list-style: none; |
|||
background-size: 400% 100%; |
|||
margin-top: 0.9rem; |
|||
background-position: 100% 50%; |
|||
animation: skeleton-loading 1.4s ease infinite; |
|||
} |
|||
|
|||
.li:first-child { |
|||
width: 38%; |
|||
} |
|||
|
|||
.li:last-child { |
|||
width: 61%; |
|||
} |
|||
|
|||
@keyframes skeleton-loading { |
|||
0% { |
|||
background-position: 100% 50%; |
|||
} |
|||
|
|||
100% { |
|||
background-position: 0 50%; |
|||
} |
|||
} |
Loading…
Reference in new issue