[bugfix] functional component multi listeners (#2717)

This commit is contained in:
neverland
2019-02-12 10:44:40 +08:00
committed by GitHub
parent 0bf4a9e799
commit e6584a28d3
11 changed files with 45 additions and 29 deletions

View File

@@ -1,5 +1,5 @@
import { use } from '../utils';
import { inheritContext } from '../utils/functional';
import { emit, inherit } from '../utils/functional';
import Loading from '../loading';
const [sfc, bem] = use('button');
@@ -32,12 +32,12 @@ export default sfc({
},
render(h, context) {
const { props, listeners } = context;
const { props } = context;
const { type, disabled, loading } = props;
const onClick = event => {
if (!loading && !disabled && listeners.click) {
listeners.click(event);
if (!loading && !disabled) {
emit(context, 'click', event);
}
};
@@ -59,7 +59,7 @@ export default sfc({
}
])}
onClick={onClick}
{...inheritContext(context)}
{...inherit(context)}
>
{loading ? (
<Loading size="20px" color={type === 'default' ? undefined : ''} />