diff --git a/src/dropdown-item/index.js b/src/dropdown-item/index.js index 8987fbc72..d7c400d77 100644 --- a/src/dropdown-item/index.js +++ b/src/dropdown-item/index.js @@ -56,6 +56,7 @@ export default createComponent({ }, methods: { + // @exposed-api toggle(show = !this.showPopup, options = {}) { if (show === this.showPopup) { return; diff --git a/src/dropdown-menu/README.zh-CN.md b/src/dropdown-menu/README.zh-CN.md index e3b340eb5..c6d282711 100644 --- a/src/dropdown-menu/README.zh-CN.md +++ b/src/dropdown-menu/README.zh-CN.md @@ -158,7 +158,7 @@ export default { | 方法名 | 说明 | 参数 | 返回值 | |------|------|------|------| -| toggle | 切换菜单是否展示 | show: boolean | - | +| toggle | 切换菜单展示状态,传`true`为显示,`false`为隐藏,不传参为取反 | show?: boolean | - | ### Option 数据结构 diff --git a/types/dropdown-item.d.ts b/types/dropdown-item.d.ts new file mode 100644 index 000000000..84f21eea8 --- /dev/null +++ b/types/dropdown-item.d.ts @@ -0,0 +1,5 @@ +import { VanComponent } from './component'; + +export class DropdownItem extends VanComponent { + toggle(show?: boolean): void; +}