[improvement] Info: tsx (#2768)

This commit is contained in:
neverland
2019-02-17 18:09:26 +08:00
committed by GitHub
parent a6a733f735
commit 1d84d33264
4 changed files with 46 additions and 33 deletions
-20
View File
@@ -1,20 +0,0 @@
import { use, isDef } from '../utils';
import { inherit } from '../utils/functional';
const [sfc, bem] = use('info');
function Info(h, props, slots, ctx) {
return (
isDef(props.info) && (
<div class={bem()} {...inherit(ctx, true)}>
{props.info}
</div>
)
);
}
Info.props = {
info: [String, Number]
};
export default sfc(Info);
+29
View File
@@ -0,0 +1,29 @@
import { use, isDef } from '../utils';
import { inherit } from '../utils/functional';
// Types
import { FunctionalComponent } from '../utils/use/sfc';
const [sfc, bem] = use('info');
const Info: FunctionalComponent<InfoProps> = function(h, props, slots, ctx) {
if (!isDef(props.info)) {
return;
}
return (
<div class={bem()} {...inherit(ctx, true)}>
{props.info}
</div>
);
};
export type InfoProps = {
info?: string | number;
};
Info.props = {
info: [String, Number]
};
export default sfc(Info);