mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-26 00:09:15 +08:00
feat(Col): add click event (#4169)
This commit is contained in:
parent
66f3aac389
commit
6b8fbfb290
@ -106,3 +106,9 @@ Setting `type` to `flex` to enable flex layout
|
|||||||
| span | number of column the grid spans | `string | number` | - |
|
| span | number of column the grid spans | `string | number` | - |
|
||||||
| 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` |
|
||||||
|
|
||||||
|
### Col Events
|
||||||
|
|
||||||
|
| Event | Description | Arguments |
|
||||||
|
|------|------|------|
|
||||||
|
| click | Triggered when click col | event: Event |
|
||||||
|
@ -109,3 +109,9 @@ Layout 组件提供了`24列栅格`,通过在`Col`上添加`span`属性设置
|
|||||||
| span | 列元素宽度 | `string | number` | - | - |
|
| span | 列元素宽度 | `string | number` | - | - |
|
||||||
| offset | 列元素偏移距离 | `string | number` | - | - |
|
| offset | 列元素偏移距离 | `string | number` | - | - |
|
||||||
| tag | 自定义元素标签 | `string` | `div` | - |
|
| tag | 自定义元素标签 | `string` | `div` | - |
|
||||||
|
|
||||||
|
### Col Events
|
||||||
|
|
||||||
|
| 事件名 | 说明 | 回调参数 |
|
||||||
|
|------|------|------|
|
||||||
|
| click | 点击时触发 | event: Event |
|
||||||
|
@ -23,10 +23,20 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
onClick(event) {
|
||||||
|
this.$emit('click', event);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { span, offset } = this;
|
const { span, offset } = this;
|
||||||
return (
|
return (
|
||||||
<this.tag class={bem({ [span]: span, [`offset-${offset}`]: offset })} style={this.style}>
|
<this.tag
|
||||||
|
style={this.style}
|
||||||
|
class={bem({ [span]: span, [`offset-${offset}`]: offset })}
|
||||||
|
onClick={this.onClick}
|
||||||
|
>
|
||||||
{this.slots()}
|
{this.slots()}
|
||||||
</this.tag>
|
</this.tag>
|
||||||
);
|
);
|
||||||
|
9
src/col/test/index.spec.js
Normal file
9
src/col/test/index.spec.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import Col from '..';
|
||||||
|
import { mount } from '../../../test/utils';
|
||||||
|
|
||||||
|
test('Col click event', () => {
|
||||||
|
const wrapper = mount(Col);
|
||||||
|
wrapper.trigger('click');
|
||||||
|
|
||||||
|
expect(wrapper.emitted('click')).toBeTruthy();
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user