diff --git a/packages/button/index.js b/packages/button/index.js
index ce4048ec0..11944c04e 100644
--- a/packages/button/index.js
+++ b/packages/button/index.js
@@ -3,65 +3,70 @@ import Loading from '../loading';
const [sfc, bem] = use('button');
-export default sfc({
- props: {
- text: String,
- block: Boolean,
- plain: Boolean,
- round: Boolean,
- square: Boolean,
- loading: Boolean,
- disabled: Boolean,
- nativeType: String,
- bottomAction: Boolean,
- tag: {
- type: String,
- default: 'button'
- },
- type: {
- type: String,
- default: 'default'
- },
- size: {
- type: String,
- default: 'normal'
- }
- },
-
- methods: {
- onClick(event) {
- if (!this.loading && !this.disabled) {
- this.$emit('click', event);
+export default sfc(
+ {
+ props: {
+ text: String,
+ block: Boolean,
+ plain: Boolean,
+ round: Boolean,
+ square: Boolean,
+ loading: Boolean,
+ disabled: Boolean,
+ nativeType: String,
+ bottomAction: Boolean,
+ tag: {
+ type: String,
+ default: 'button'
+ },
+ type: {
+ type: String,
+ default: 'default'
+ },
+ size: {
+ type: String,
+ default: 'normal'
}
+ },
+
+ render(h, context, inherit) {
+ const { props, listeners } = context;
+ const { type, disabled, loading } = props;
+
+ const onClick = event => {
+ if (!loading && !disabled && listeners.click) {
+ listeners.click(event);
+ }
+ };
+
+ return (
+
+ {loading ? (
+
+ ) : (
+ {context.children || props.text}
+ )}
+
+ );
}
},
-
- render(h) {
- return (
-
- {this.loading ? (
-
- ) : (
- {this.$slots.default || this.text}
- )}
-
- );
- }
-});
+ true
+);
diff --git a/packages/contact-list/index.js b/packages/contact-list/index.js
index 58ad9f4c2..e3bc0cd2f 100644
--- a/packages/contact-list/index.js
+++ b/packages/contact-list/index.js
@@ -15,7 +15,7 @@ export default sfc(
addText: String
},
- render(h, context) {
+ render(h, context, inherit) {
const { props, listeners } = context;
const List = props.list.map((item, index) => (
@@ -43,7 +43,7 @@ export default sfc(
));
return (
-
+
{List}
diff --git a/packages/nav-bar/index.js b/packages/nav-bar/index.js
index 8013014d5..945738627 100644
--- a/packages/nav-bar/index.js
+++ b/packages/nav-bar/index.js
@@ -21,7 +21,7 @@ export default sfc(
}
},
- render(h, context) {
+ render(h, context, inherit) {
const { props, listeners } = context;
const slots = context.slots();
@@ -29,7 +29,7 @@ export default sfc(
+
{slots.top}
{(slots.tip || tip) && (
diff --git a/packages/submit-bar/test/__snapshots__/demo.spec.js.snap b/packages/submit-bar/test/__snapshots__/demo.spec.js.snap
index c73a59f37..2aba55f7d 100644
--- a/packages/submit-bar/test/__snapshots__/demo.spec.js.snap
+++ b/packages/submit-bar/test/__snapshots__/demo.spec.js.snap
@@ -13,14 +13,14 @@ exports[`renders demo correctly 1`] = `
你的收货地址不支持同城送, 我们已为你推荐快递
-
合计:¥ 30.50
+
合计:¥ 30.50
-
合计:¥ 30.50
diff --git a/packages/submit-bar/test/__snapshots__/index.spec.js.snap b/packages/submit-bar/test/__snapshots__/index.spec.js.snap
index be6067098..137322232 100644
--- a/packages/submit-bar/test/__snapshots__/index.spec.js.snap
+++ b/packages/submit-bar/test/__snapshots__/index.spec.js.snap
@@ -3,7 +3,7 @@
exports[`disable submit 1`] = `
`;
diff --git a/packages/switch-cell/index.js b/packages/switch-cell/index.js
index e9e297683..8533b7e09 100644
--- a/packages/switch-cell/index.js
+++ b/packages/switch-cell/index.js
@@ -18,7 +18,7 @@ export default sfc(
}
},
- render(h, context) {
+ render(h, context, inherit) {
const { props } = context;
return (
@@ -26,8 +26,8 @@ export default sfc(
center
title={props.title}
border={props.border}
- style={context.style}
- class={[bem(), context.class, context.staticClass]}
+ class={bem()}
+ {...inherit}
>
diff --git a/packages/utils/use/sfc.js b/packages/utils/use/sfc.js
index 257108293..5c7a57368 100644
--- a/packages/utils/use/sfc.js
+++ b/packages/utils/use/sfc.js
@@ -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;