Popup - 图1

Popup Vue Component

Popup is a popup window with any HTML content that pops up over App’s main content. Popup as all other overlays is part of so called “Temporary Views”.

Popup Vue component represents Popup component.

Popup Components

There are following components included:

  • **f7-popup** - popup element

Popup Properties

PropTypeDescription
<f7-popup> properties
tablet-fullscreenbooleanDefines whether the popup should be displayed fullscreen on tablets or not
openedbooleanAllows to open/close Popup and set its initial state
backdropbooleanEnables Popup backdrop (dark semi transparent layer behind). By default inherits same app parameter value (true)
closeByBackdropClickbooleanWhen enabled, popup will be closed on backdrop click. By default inherits same app parameter value (true)
animatebooleanWhether the Popup should be opened/closed with animation or not. Can be overwritten in .open() and .close() methods. By default inherits same app parameter value (true)

Popup Methods

<f7-popup> methods
.open(animate)Open popup
.close(animate)Close popup

Popup Events

EventDescription
<f7-popup> events
popup:openEvent will be triggered when Popup starts its opening animation
popup:openedEvent will be triggered after Popup completes its opening animation
popup:closeEvent will be triggered when Popup starts its closing animation
popup:closedEvent will be triggered after Popup completes its closing animation

Open And Close Popup

You can control Popup state, open and closing it:

  • using Popup API
  • by passing true or false to its opened prop
  • by clicking on Link or Button with relevant popup-open property (to open it) and popup-close property to close it

Access To Popup Instance

You can access Popup initialized instance by accessing **.f7Popup** component’s property.

Examples

  1. <template>
  2. <f7-page @page:beforeremove="onPageBeforeRemove">
  3. <f7-navbar title="Popup"></f7-navbar>
  4. <f7-block>
  5. <p>
  6. <f7-button raised popup-open=".demo-popup">Open Popup</f7-button>
  7. </p>
  8. <p>
  9. <f7-button raised @click="popupOpened = true">Open Via Prop Change</f7-button>
  10. </p>
  11. <p>
  12. <f7-button raised @click="createPopup">Create Dynamic Popup</f7-button>
  13. </p>
  14. </f7-block>
  15. <f7-popup class="demo-popup" :opened="popupOpened" @popup:closed="popupOpened = false">
  16. <f7-page>
  17. <f7-navbar title="Popup Title">
  18. <f7-nav-right>
  19. <f7-link popup-close>Close</f7-link>
  20. </f7-nav-right>
  21. </f7-navbar>
  22. <f7-block>
  23. <p>Here comes popup. You can put here anything, even independent view with its own navigation. Also not, that by default popup looks a bit different on iPhone/iPod and iPad, on iPhone it is fullscreen.</p>
  24. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit...</p>
  25. <p>Duis ut mauris sollicitudin, venenatis nisi sed, luctus ligula...</p>
  26. </f7-block>
  27. </f7-page>
  28. </f7-popup>
  29. </f7-page>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. popupOpened: false,
  36. };
  37. },
  38. methods: {
  39. createPopup() {
  40. const self = this;
  41. // Create popup
  42. if (!self.popup) {
  43. self.popup = self.$f7.popup.create({
  44. content: `
  45. <div class="popup">
  46. <div class="page">
  47. <div class="navbar">
  48. <div class="navbar-inner">
  49. <div class="title">Dynamic Popup</div>
  50. <div class="right"><a href="#" class="link popup-close">Close</a></div>
  51. </div>
  52. </div>
  53. <div class="page-content">
  54. <div class="block">
  55. <p>This popup was created dynamically</p>
  56. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse faucibus mauris leo, eu bibendum neque congue non...</p>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. `.trim(),
  62. });
  63. }
  64. // Open it
  65. self.popup.open();
  66. },
  67. onPageBeforeRemove() {
  68. const self = this;
  69. // Destroy popup when page removed
  70. if (self.popup) self.popup.destroy();
  71. },
  72. },
  73. };
  74. </script>