feat(ShareSheet): add className option (#6886)

* feat: van-share-sheet支持设置分享选项的类名

* Update README.zh-CN.md

* Update README.md

* Update index.vue

* fix: 添加一些van-share-sheet测试用例

* fix: change van-share-sheet test code

Co-authored-by: neverland <416417567@163.com>
This commit is contained in:
月光倾城 2020-07-28 10:59:30 +08:00 committed by GitHub
parent 64bec01a73
commit d922c2baaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 1 deletions

View File

@ -130,6 +130,7 @@ export default {
| name | Option name | _string_ |
| description `v2.8.5` | Option description | _string_ |
| icon | Option iconcan be set to `wechat` `weibo` `qq` `link` `qrcode` `poster` or image URL | _string_ |
| className | Option className is used to set the class props to the share item | _string_ |
### Events

View File

@ -178,6 +178,7 @@ export default {
| name | 分享渠道名称 | _string_ |
| description `v2.8.5` | 分享选项描述 | _string_ |
| icon | 图标,可选值为 `wechat` `weibo` `qq` `link` `qrcode` `poster`,支持传入图片 URL | _string_ |
| className | 分享选项类名 | _string_ |
### Events

View File

@ -85,7 +85,7 @@ export default createComponent({
<div
role="button"
tabindex="0"
class={bem('option')}
class={[bem('option'), option.className]}
onClick={() => {
this.onSelect(option, index);
}}

View File

@ -29,6 +29,19 @@ test('description prop', () => {
expect(wrapper.contains('.van-share-sheet__description')).toBeFalsy();
});
test('option className', () => {
const wrapper = mount(ShareSheet, {
propsData: {
value: true,
options: [{ name: 'Link', icon: 'link', className: 'foo' }],
},
});
const option = wrapper.find('.van-share-sheet__option').element;
expect(option.className.includes('foo')).toBeTruthy();
});
test('select event', () => {
const wrapper = mount(ShareSheet, {
propsData: {