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 can be imported from framework7-vue package.

f7ready

It is a callback 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:

<template>
  ...
</template>
<script>
  import { f7ready } from 'framework7-vue';

  export default {
    ...
    mounted() {
      f7ready((f7) => {
        f7.dialog.alert('Component mounted');
      });
    },
  };
</script>

f7

Main Framework7's initialized instance. It allows you to use any of Framework7 APIs.

If you are sure that on the moment when you access Framework7 instance, it was already initialized, you can import and use it directly:

<template>
  ...
</template>
<script>
  import { f7 } from 'framework7-vue';

  export default {
    ...
    methods: {
      doSomething() {
        f7.dialog.alert('Hello world');
      }
    },
  };
</script>

theme

It is an object with boolean properties with information about currently used theme (iOS, MD or Aurora ): theme.ios, theme.md and theme.aurora.

<template>
  ...
</template>
<script>
  import { theme } from 'framework7-vue';

  export default {
    ...
    mounted() {
      if (theme.ios) {
        console.log('Currently active theme is iOS-theme')
      }
    },
  };
</script>

f7route and f7router

Router instance and current route are passed via props to router components:

This properties 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.

<template>
  ...
</template>
<script>
  export default {
    // define props so the component will receive it
    props: {
      f7route: Object,
      f7router: Object,
    },
    ...
    mounted() {
      console.log(this.f7route.url)
    },
    methods: {
      navigate() {
        this.f7router.navigate('/some-page/')
      }
    }
  };
</script>

f7route is the current route, object with 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