diff --git a/src/skeleton/index.js b/src/skeleton/index.js index c7b767726..83aedd3bf 100644 --- a/src/skeleton/index.js +++ b/src/skeleton/index.js @@ -40,68 +40,66 @@ export default createComponent({ }, setup(props, { slots }) { - return function () { + const renderAvatar = () => { + if (props.avatar) { + const size = addUnit(props.avatarSize); + return ( +
+ ); + } + }; + + const renderTitle = () => { + if (props.title) { + return ( + + ); + } + }; + + const getRowWidth = (index) => { + const { rowWidth } = props; + + if (rowWidth === DEFAULT_ROW_WIDTH && index === +props.row - 1) { + return DEFAULT_LAST_ROW_WIDTH; + } + + if (Array.isArray(rowWidth)) { + return rowWidth[index]; + } + + return rowWidth; + }; + + const renderRows = () => { + const Rows = []; + + for (let i = 0; i < props.row; i++) { + Rows.push( + + ); + } + + return Rows; + }; + + return () => { if (!props.loading) { - return slots.default && slots.default(); - } - - function Title() { - if (props.title) { - return ( - - ); - } - } - - function Rows() { - const Rows = []; - const { rowWidth } = props; - - function getRowWidth(index) { - if (rowWidth === DEFAULT_ROW_WIDTH && index === +props.row - 1) { - return DEFAULT_LAST_ROW_WIDTH; - } - - if (Array.isArray(rowWidth)) { - return rowWidth[index]; - } - - return rowWidth; - } - - for (let i = 0; i < props.row; i++) { - Rows.push( - - ); - } - - return Rows; - } - - function Avatar() { - if (props.avatar) { - const size = addUnit(props.avatarSize); - return ( - - ); - } + return slots.default?.(); } return (