style: slots.default?.()

pull/3053/head
Amour1688 2020-10-24 20:36:57 +08:00
parent 6891c38705
commit d219ff1655
16 changed files with 16 additions and 18 deletions

View File

@ -68,7 +68,7 @@ const TransButton = defineComponent({
onKeyup={this.onKeyUp} onKeyup={this.onKeyUp}
style={{ ...(!noStyle ? inlineStyle : null) }} style={{ ...(!noStyle ? inlineStyle : null) }}
> >
{this.$slots.default && this.$slots.default()} {this.$slots.default?.()}
</div> </div>
); );
}, },

View File

@ -169,6 +169,6 @@ export default defineComponent({
if (csp) { if (csp) {
this.csp = csp; this.csp = csp;
} }
return this.$slots.default && this.$slots.default()[0]; return this.$slots.default?.()[0];
}, },
}); });

View File

@ -258,7 +258,7 @@ const Affix = defineComponent({
> >
<div {...props} style={placeholderStyle} ref="placeholderNode"> <div {...props} style={placeholderStyle} ref="placeholderNode">
<div class={className} ref="fixedNode" style={affixStyle}> <div class={className} ref="fixedNode" style={affixStyle}>
{$slots.default && $slots.default()} {$slots.default?.()}
</div> </div>
</div> </div>
</ResizeObserver> </ResizeObserver>

View File

@ -283,7 +283,7 @@ export default defineComponent({
<div class={`${prefixCls}-ink`}> <div class={`${prefixCls}-ink`}>
<span class={inkClass} ref="inkNode" /> <span class={inkClass} ref="inkNode" />
</div> </div>
{$slots.default && $slots.default()} {$slots.default?.()}
</div> </div>
</div> </div>
); );

View File

@ -82,7 +82,7 @@ export default defineComponent({
> >
{title} {title}
</a> </a>
{$slots.default && $slots.default()} {$slots.default?.()}
</div> </div>
); );
}, },

View File

@ -118,7 +118,7 @@ export default defineComponent({
} }
: {}; : {};
let children: VueNode = this.$slots.default && this.$slots.default(); let children: VueNode = this.$slots.default?.();
if (src && isImgExist) { if (src && isImgExist) {
children = ( children = (
<img src={src} srcset={srcset || srcSet} onError={this.handleImgLoadError} alt={alt} /> <img src={src} srcset={srcset || srcSet} onError={this.handleImgLoadError} alt={alt} />

View File

@ -93,7 +93,7 @@ const BackTop = defineComponent({
}; };
const backTopBtn = this.visible ? ( const backTopBtn = this.visible ? (
<div {...divProps}>{($slots.default && $slots.default()) || defaultElement}</div> <div {...divProps}>{$slots.default?.() || defaultElement}</div>
) : null; ) : null;
const transitionProps = getTransitionProps('fade'); const transitionProps = getTransitionProps('fade');
return <Transition {...transitionProps}>{backTopBtn}</Transition>; return <Transition {...transitionProps}>{backTopBtn}</Transition>;

View File

@ -187,7 +187,7 @@ const Drawer = defineComponent({
> >
{this.renderHeader(prefixCls)} {this.renderHeader(prefixCls)}
<div key="body" class={`${prefixCls}-body`} style={bodyStyle}> <div key="body" class={`${prefixCls}-body`} style={bodyStyle}>
{this.$slots.default && this.$slots.default()} {this.$slots.default?.()}
</div> </div>
</div> </div>
); );

View File

@ -216,7 +216,7 @@ const Select = defineComponent({
dropdownClassName={rcSelectRtlDropDownClassName} dropdownClassName={rcSelectRtlDropDownClassName}
onChange={triggerChange} onChange={triggerChange}
> >
{slots.default && slots.default()} {slots.default?.()}
</RcSelect> </RcSelect>
); );
}, },

View File

@ -43,7 +43,7 @@ export default defineComponent({
[`${prefixCls}-reverse`]: !!reverse, [`${prefixCls}-reverse`]: !!reverse,
[`${prefixCls}-${mode}`]: !!mode, [`${prefixCls}-${mode}`]: !!mode,
}); });
const children = filterEmpty(this.$slots.default && this.$slots.default()); const children = filterEmpty(this.$slots.default?.());
// // Remove falsy items // // Remove falsy items
// const falsylessItems = filterEmpty(this.$slots.default) // const falsylessItems = filterEmpty(this.$slots.default)
// const items = falsylessItems.map((item, idx) => { // const items = falsylessItems.map((item, idx) => {

View File

@ -52,9 +52,7 @@ export default defineComponent({
> >
{dot} {dot}
</div> </div>
<div class={`${prefixCls}-item-content`}> <div class={`${prefixCls}-item-content`}>{this.$slots.default?.()}</div>
{this.$slots.default && this.$slots.default()}
</div>
</li> </li>
); );
}, },

View File

@ -10,7 +10,7 @@ const FunctionProvider = {
if (props.injectExtraPropsKey) { if (props.injectExtraPropsKey) {
provide(props.injectExtraPropsKey, reactive(attrs)); provide(props.injectExtraPropsKey, reactive(attrs));
} }
return () => slots.default && slots.default(); return () => slots.default?.();
}, },
}; };

View File

@ -83,7 +83,7 @@ const VueResizeObserver = defineComponent({
}, },
render() { render() {
return this.$slots.default && this.$slots.default()[0]; return this.$slots.default?.()[0];
}, },
}); });

View File

@ -40,7 +40,7 @@ const TransBtn = (props: TransBtnProps, { slots }: SetupContext) => {
icon icon
) : ( ) : (
<span class={className.split(/\s+/).map((cls: any) => `${cls}-icon`)}> <span class={className.split(/\s+/).map((cls: any) => `${cls}-icon`)}>
{slots.default && slots.default()} {slots.default?.()}
</span> </span>
)} )}
</span> </span>

View File

@ -246,7 +246,7 @@ export default {
align={align} align={align}
onAlign={this.onAlign} onAlign={this.onAlign}
> >
<PopupInner {...popupInnerProps}>{$slots.default && $slots.default()}</PopupInner> <PopupInner {...popupInnerProps}>{$slots.default?.()}</PopupInner>
</Align> </Align>
) : null} ) : null}
</Transition> </Transition>

View File

@ -13,7 +13,7 @@ export default {
return ( return (
<div class={!visible ? hiddenClassName : ''}> <div class={!visible ? hiddenClassName : ''}>
<LazyRenderBox class={`${prefixCls}-content`} visible={visible}> <LazyRenderBox class={`${prefixCls}-content`} visible={visible}>
{this.$slots.default && this.$slots.default()} {this.$slots.default?.()}
</LazyRenderBox> </LazyRenderBox>
</div> </div>
); );