[improvement] Functional: button (#2676)

This commit is contained in:
neverland
2019-02-02 17:04:02 +08:00
committed by GitHub
parent 5926d02d38
commit e3f4cac05d
8 changed files with 91 additions and 75 deletions

View File

@@ -27,10 +27,21 @@ function defaultProps(props) {
function install(Vue) {
const { name } = this;
Vue.component(name, this);
Vue.component((camelize(`-${name}`)), this);
Vue.component(camelize(`-${name}`), this);
}
export default name => (sfc, functional) => {
function functional(sfc) {
const { render } = sfc;
sfc.functional = true;
sfc.render = (h, context) =>
render(h, context, {
style: context.data.style,
class: context.data.class,
staticClass: context.data.staticClass
});
}
export default name => (sfc, isFunctional) => {
sfc.name = name;
sfc.install = install;
@@ -38,8 +49,8 @@ export default name => (sfc, functional) => {
defaultProps(sfc.props);
}
if (functional) {
sfc.functional = true;
if (isFunctional) {
functional(sfc);
}
return sfc;