mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-12-01 03:38:30 +08:00
Dropdown: Allow any type from items' command
prop
This commit is contained in:
parent
b74ccda118
commit
fb99bc90b1
@ -19,7 +19,7 @@
|
|||||||
mixins: [Emitter],
|
mixins: [Emitter],
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
command: String,
|
command: null,
|
||||||
disabled: Boolean,
|
disabled: Boolean,
|
||||||
divided: Boolean
|
divided: Boolean
|
||||||
},
|
},
|
||||||
|
@ -40,6 +40,7 @@ describe('Dropdown', () => {
|
|||||||
}, 400);
|
}, 400);
|
||||||
});
|
});
|
||||||
it('menu click', done => {
|
it('menu click', done => {
|
||||||
|
const myCommandObject = { name: 'CommandC' };
|
||||||
vm = createVue({
|
vm = createVue({
|
||||||
template: `
|
template: `
|
||||||
<el-dropdown ref="dropdown">
|
<el-dropdown ref="dropdown">
|
||||||
@ -49,12 +50,17 @@ describe('Dropdown', () => {
|
|||||||
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-menu slot="dropdown">
|
||||||
<el-dropdown-item command="a">黄金糕</el-dropdown-item>
|
<el-dropdown-item command="a">黄金糕</el-dropdown-item>
|
||||||
<el-dropdown-item command="b">狮子头</el-dropdown-item>
|
<el-dropdown-item command="b">狮子头</el-dropdown-item>
|
||||||
<el-dropdown-item ref="commandC" command="c">螺蛳粉</el-dropdown-item>
|
<el-dropdown-item ref="commandC" :command="myCommandObject">螺蛳粉</el-dropdown-item>
|
||||||
<el-dropdown-item command="d">双皮奶</el-dropdown-item>
|
<el-dropdown-item command="d">双皮奶</el-dropdown-item>
|
||||||
<el-dropdown-item command="e">蚵仔煎</el-dropdown-item>
|
<el-dropdown-item command="e">蚵仔煎</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
`
|
`,
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
myCommandObject
|
||||||
|
};
|
||||||
|
}
|
||||||
}, true);
|
}, true);
|
||||||
let dropdown = vm.$refs.dropdown;
|
let dropdown = vm.$refs.dropdown;
|
||||||
let dropdownElm = dropdown.$el;
|
let dropdownElm = dropdown.$el;
|
||||||
@ -68,7 +74,7 @@ describe('Dropdown', () => {
|
|||||||
vm.$refs.commandC.$el.click();
|
vm.$refs.commandC.$el.click();
|
||||||
setTimeout(_ => {
|
setTimeout(_ => {
|
||||||
expect(dropdown.visible).to.not.true;
|
expect(dropdown.visible).to.not.true;
|
||||||
expect(callback.calledWith('c')).to.be.true;
|
expect(callback.calledWith(myCommandObject)).to.be.true;
|
||||||
destroyVM(vm);
|
destroyVM(vm);
|
||||||
done();
|
done();
|
||||||
}, 300);
|
}, 300);
|
||||||
|
Loading…
Reference in New Issue
Block a user