mirror of
https://github.com/youzan/vant.git
synced 2026-05-05 01:00:55 +08:00
[improvement] GoodsAction: jsx (#2513)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { use } from '../utils';
|
||||
import Icon from '../icon';
|
||||
import RouterLink from '../mixins/router-link';
|
||||
|
||||
const [sfc, bem] = use('goods-action-mini-btn');
|
||||
|
||||
export default sfc({
|
||||
mixins: [RouterLink],
|
||||
|
||||
props: {
|
||||
text: String,
|
||||
info: [String, Number],
|
||||
icon: String,
|
||||
iconClass: String
|
||||
},
|
||||
|
||||
methods: {
|
||||
onClick(event) {
|
||||
this.$emit('click', event);
|
||||
this.routerLink();
|
||||
}
|
||||
},
|
||||
|
||||
render(h) {
|
||||
return (
|
||||
<div class={[bem(), 'van-hairline']} onClick={this.onClick}>
|
||||
<Icon class={[bem('icon'), this.iconClass]} info={this.info} name={this.icon} />
|
||||
{this.$slots.default || this.text}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -1,39 +0,0 @@
|
||||
<template>
|
||||
<div
|
||||
:class="b()"
|
||||
class="van-hairline"
|
||||
@click="onClick"
|
||||
>
|
||||
<icon
|
||||
:class="[b('icon'), iconClass]"
|
||||
:info="info"
|
||||
:name="icon"
|
||||
/>
|
||||
<slot>{{ text }}</slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import create from '../utils/create';
|
||||
import RouterLink from '../mixins/router-link';
|
||||
|
||||
export default create({
|
||||
name: 'goods-action-mini-btn',
|
||||
|
||||
mixins: [RouterLink],
|
||||
|
||||
props: {
|
||||
text: String,
|
||||
info: [String, Number],
|
||||
icon: String,
|
||||
iconClass: String
|
||||
},
|
||||
|
||||
methods: {
|
||||
onClick(event) {
|
||||
this.$emit('click', event);
|
||||
this.routerLink();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user