Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[new feature] Card: add click-thumb event #3586

Merged
merged 3 commits into from Jun 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/card/en-US.md
Expand Up @@ -65,6 +65,7 @@ Use slot to custom content.
| Event | Description | Arguments |
|------|------|------|
| click | Triggered when clicked | - |
| click-thumb | Triggered when thumb clicked | - |

### Slots

Expand Down
8 changes: 6 additions & 2 deletions packages/card/index.tsx
@@ -1,5 +1,5 @@
import { use, isDef } from '../utils';
import { inherit } from '../utils/functional';
import { emit, inherit } from '../utils/functional';
import Tag from '../tag';
import Image from '../image';

Expand Down Expand Up @@ -53,6 +53,10 @@ function Card(
const showOriginPrice = slots['origin-price'] || isDef(props.originPrice);
const showBottom = showNum || showPrice || showOriginPrice;

const onThumbClick = () => {
emit(ctx, 'click-thumb');
};

function ThumbTag() {
if (slots.tag || props.tag) {
return (
Expand All @@ -72,7 +76,7 @@ function Card(
function Thumb() {
if (slots.thumb || thumb) {
return (
<a href={props.thumbLink} class={bem('thumb')}>
<a href={props.thumbLink} class={bem('thumb')} onClick={onThumbClick}>
{slots.thumb ? (
slots.thumb()
) : (
Expand Down
1 change: 1 addition & 0 deletions packages/card/zh-CN.md
Expand Up @@ -65,6 +65,7 @@ Vue.use(Card);
| 事件名 | 说明 | 回调参数 |
|------|------|------|
| click | 点击时触发 | - |
| click-thumb | 点击自定义图片时触发 | - |

### Slots

Expand Down