react-native-navigation的迁移库

api-modal.mdx 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ---
  2. id: modal
  3. title: Modal
  4. sidebar_label: Modal
  5. ---
  6. ## `showModal()`
  7. Show a screen as a modal.
  8. #### Parameters
  9. | Name | Required | Type | Description |
  10. | ------ | -------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------- |
  11. | layout | Yes | [Layout](layout-layout.mdx) | Any type of layout. [BottomTabs](layout-BottomTabs.mdx), [Stack](layout-stack.mdx), [SideMenu](layout-sideMenu.mdx), [Component](layout-component.mdx) |
  12. ```js
  13. Navigation.showModal({
  14. stack: {
  15. children: [{
  16. component: {
  17. name: 'example.ModalScreen',
  18. passProps: {
  19. text: 'stack with one child'
  20. },
  21. options: {
  22. topBar: {
  23. title: {
  24. text: 'Modal'
  25. }
  26. }
  27. }
  28. }
  29. }]
  30. }
  31. });
  32. ```
  33. ## `dismissModal()`
  34. Dismiss the current modal.
  35. #### Parameters
  36. | Name | Required | Type | Description |
  37. | ------------ | -------- | ------- | ---------------------------------------------------------- |
  38. | componentId | Yes | string | Any component id presented in the modal |
  39. | mergeOptions | No | Options | Options to be merged before dismissing the Modal. |
  40. ```js
  41. Navigation.dismissModal(this.props.componentId);
  42. ```
  43. ## `dismissAllModals()`
  44. Dismiss all current modals at the same time.
  45. #### Parameters
  46. | Name | Required | Type | Description |
  47. | ------------ | -------- | ------- | ---------------------------------------------------------- |
  48. | mergeOptions | No | Options | Options to be merged before dismissing all modals. |
  49. ```js
  50. Navigation.dismissAllModals();
  51. ```