Skip to content
This repository has been archived by the owner on May 2, 2020. It is now read-only.

this.$f7 is undefined #606

Closed
opichon opened this issue Jun 20, 2017 · 2 comments
Closed

this.$f7 is undefined #606

opichon opened this issue Jun 20, 2017 · 2 comments
Labels

Comments

@opichon
Copy link
Contributor

opichon commented Jun 20, 2017

Inside the app component, this.$f7 appears to be undefined.

I am using the loginc from the app-component.md docs, namely adding thisto app.vue:

<script>
  export default {
    mounted: function () {
      this.$f7.alert('App is mounted!')
    }
  }
</script>

In the browser, the following error is reported:

vue.common.js:525 TypeError: Cannot read property 'alert' of undefined
    at VueComponent.mounted (app.vue:40)

If instead I just do console.log(this) then I can see that there is no $f7 property.

@jrpereirajr
Copy link

jrpereirajr commented Jun 21, 2017

Same here, just this.$f7Router is available.

After some readings, I found this way in order to work:

<script>
export default {
	mounted: function () {
		// this.$f7.alert('App is mounted!')
		setTimeout(function(){
			window.f7.alert('App is mounted!')
		}, 100);
	}
}
</script>

But I think this isn't the right way to handle this... :)

@scriptPilot
Copy link
Owner

scriptPilot commented Jun 22, 2017

@opichonm @jrpereirajr - Documentation is updated, thanks - please follow Framework7 way of working:

methods: {
  onF7Init: function () {
    this.$f7.alert('App is mounted!')        
  }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants