mirror of
https://github.com/youzan/vant.git
synced 2025-10-18 17:51:54 +00:00
[new feature] add Tabbar component (#204)
* [Document] add english document of Checkbox * [Document] add english document of Field * [Document] add english document of NumberKeyboard * [bugfix] NumberKeyboard should not dispaly title when title is empty * [Document] add english document of PasswordInput * [Document] add english document of Radio * [document] add english document of Switch * [bugfix] remove redundent styles in english document * [Document] fix details * fix Switch test cases * [bugfix] Swipe shouid reinitialize when item changes * [new feature] ImagePreview reconstruct * [new feature] add Tabbar component
This commit is contained in:
40
test/unit/components/tabbar.vue
Normal file
40
test/unit/components/tabbar.vue
Normal file
@@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<van-tabbar v-model="active" @change="onChange">
|
||||
<van-tabbar-item icon="shop">
|
||||
<span>自定义</span>
|
||||
<img slot="icon" :src="active === 0 ? icon.active : icon.normal" />
|
||||
</van-tabbar-item>
|
||||
<van-tabbar-item icon="chat">标签</van-tabbar-item>
|
||||
<van-tabbar-item icon="chat">标签</van-tabbar-item>
|
||||
<van-tabbar-item icon="records">标签</van-tabbar-item>
|
||||
</van-tabbar>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Tabbar from 'packages/tabbar';
|
||||
import TabbarItem from 'packages/tabbar-item';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
[Tabbar.name]: Tabbar,
|
||||
[TabbarItem.name]: TabbarItem
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
active: 0,
|
||||
changeRecord: 0,
|
||||
icon: {
|
||||
normal: 'https://img.yzcdn.cn/public_files/2017/10/13/c547715be149dd3faa817e4a948b40c4.png',
|
||||
active: 'https://img.yzcdn.cn/public_files/2017/10/13/793c77793db8641c4c325b7f25bf130d.png'
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
onChange(val) {
|
||||
this.changeRecord = val;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
23
test/unit/specs/tabbar.spec.js
Normal file
23
test/unit/specs/tabbar.spec.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import TabbarExample from '../components/tabbar';
|
||||
import { mount } from 'avoriaz';
|
||||
|
||||
describe('Progress', () => {
|
||||
let wrapper;
|
||||
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
});
|
||||
|
||||
it('Tabbar with four items', (done) => {
|
||||
wrapper = mount(TabbarExample);
|
||||
|
||||
wrapper.vm.$nextTick(() => {
|
||||
expect(wrapper.find('.van-tabbar-item').length).to.equal(4);
|
||||
|
||||
wrapper.find('.van-tabbar-item')[3].element.click();
|
||||
expect(wrapper.vm.active).to.equal(3);
|
||||
expect(wrapper.vm.changeRecord).to.equal(3);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user