mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Row): add click event (#4170)
This commit is contained in:
parent
6b8fbfb290
commit
71501d0ac1
@ -107,6 +107,12 @@ Setting `type` to `flex` to enable flex layout
|
|||||||
| offset | number of spacing on the left side of the grid | `string | number` | - |
|
| offset | number of spacing on the left side of the grid | `string | number` | - |
|
||||||
| tag | Custom element tag | `string` | `div` |
|
| tag | Custom element tag | `string` | `div` |
|
||||||
|
|
||||||
|
### Row Events
|
||||||
|
|
||||||
|
| Event | Description | Arguments |
|
||||||
|
|------|------|------|
|
||||||
|
| click | Triggered when click row | event: Event |
|
||||||
|
|
||||||
### Col Events
|
### Col Events
|
||||||
|
|
||||||
| Event | Description | Arguments |
|
| Event | Description | Arguments |
|
||||||
|
@ -110,6 +110,12 @@ Layout 组件提供了`24列栅格`,通过在`Col`上添加`span`属性设置
|
|||||||
| offset | 列元素偏移距离 | `string | number` | - | - |
|
| offset | 列元素偏移距离 | `string | number` | - | - |
|
||||||
| tag | 自定义元素标签 | `string` | `div` | - |
|
| tag | 自定义元素标签 | `string` | `div` | - |
|
||||||
|
|
||||||
|
### Row Events
|
||||||
|
|
||||||
|
| 事件名 | 说明 | 回调参数 |
|
||||||
|
|------|------|------|
|
||||||
|
| click | 点击时触发 | event: Event |
|
||||||
|
|
||||||
### Col Events
|
### Col Events
|
||||||
|
|
||||||
| 事件名 | 说明 | 回调参数 |
|
| 事件名 | 说明 | 回调参数 |
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import Col from '..';
|
import Col from '..';
|
||||||
|
import Row from '../../row';
|
||||||
import { mount } from '../../../test/utils';
|
import { mount } from '../../../test/utils';
|
||||||
|
|
||||||
test('Col click event', () => {
|
test('Col click event', () => {
|
||||||
@ -7,3 +8,10 @@ test('Col click event', () => {
|
|||||||
|
|
||||||
expect(wrapper.emitted('click')).toBeTruthy();
|
expect(wrapper.emitted('click')).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Row click event', () => {
|
||||||
|
const wrapper = mount(Row);
|
||||||
|
wrapper.trigger('click');
|
||||||
|
|
||||||
|
expect(wrapper.emitted('click')).toBeTruthy();
|
||||||
|
});
|
||||||
|
@ -17,6 +17,12 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
onClick(event) {
|
||||||
|
this.$emit('click', event);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { align, justify } = this;
|
const { align, justify } = this;
|
||||||
const flex = this.type === 'flex';
|
const flex = this.type === 'flex';
|
||||||
@ -31,6 +37,7 @@ export default createComponent({
|
|||||||
[`align-${align}`]: flex && align,
|
[`align-${align}`]: flex && align,
|
||||||
[`justify-${justify}`]: flex && justify
|
[`justify-${justify}`]: flex && justify
|
||||||
})}
|
})}
|
||||||
|
onClick={this.onClick}
|
||||||
>
|
>
|
||||||
{this.slots()}
|
{this.slots()}
|
||||||
</this.tag>
|
</this.tag>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user