Vue Component Extensions

After Vue mounts the app and init Framework7, we will have access to Framework7’s initialized instance and some other useful properties that will be available in all Vue components:

this.$f7readyCallback function that will be executed when Framework7 fully intialized. Useful to use in components when you need to access Framework7 API and to be sure it is ready. So it is safe to put all Framework7 related logic into this callback. As an argument it receives initialized Framework7 instance. For example:
  1. <template>
  2. </template>
  3. <script>
  4. export default {
  5. mounted() {
  6. this.$f7ready((f7) => {
  7. f7.dialog.alert(‘Component mounted’);
  8. });
  9. },
  10. };
  11. </script>
this.$f7Main Framework7’s initialized instance. It allows you to use any of Framework7 APIs
this.$$
this.Dom7
Access to built-in Dom7 DOM library that utilizes most edge and high-performance methods for DOM manipulation
this.$deviceAccess to Device utilities
this.$requestAccess to Request library for XHR requests
this.$utilsAccess to Utils object with few useful utilities
this.$themeObject with boolean properties with information about currently used theme (iOS, MD or Aurora ): this.$theme.ios, this.$theme.material and this.$theme.aurora
this.$f7router

This property only available for components loaded with router (e.g. pages, routable modals, routable tabs). If you need to access this property in “deeper” child components, then you need to pass it down using props.

Framework7 Router Instance. It has a lot of useful Methods & Properties to use for navigation

this.$f7route

This property only available for components loaded with router (e.g. pages, routable modals, routable tabs). If you need to access this property in “deeper” child components, then you need to pass it down using props.

Object with current route data that was used to load this page, tab or modal. It has the following properties

  • url - route URL
  • path - route path
  • query - object with route query. If the url is /page/?id=5&foo=bar then it will contain the following object {id: ‘5’, foo: ‘bar’}
  • params - route params. If we have matching route with /page/user/:userId/post/:postId/ path and url of the page is /page/user/55/post/12/ then it will be the following object {userId: ‘55’, postId: ‘12’}
  • name - route name
  • hash - route URL hash
  • route - object with matching route from available routes
  • context - context that was passed to the route

If you use functional components, then previously described extensions will not work. Framework7 instance, f7ready method and theme can be imported directly from Framework7-Vue library. Device, Request and Support can be imported directly from Framework7 core library.

  1. import { Device, Request, Support } from 'framework7';
  2. import { f7, f7ready, theme } from 'framework7-vue';
  1. <template>
  2. ...
  3. </template>
  4. <script>
  5. import { f7, f7ready } from 'framework7-vue';
  6. export default {
  7. ...
  8. mounted() {
  9. f7ready(() => {
  10. f7.dialog.alert('Component mounted');
  11. })
  12. },
  13. };
  14. </script>

← Initialize App

Navigation / Router →