[Vuejs]-Am I able to use properties on the index.html file on the vuejs mount element?

0👍

Solved my problem

I was able to get the properties from the index.html mount into my App.vue file using

  beforeMount() {
    this.neededData = this.$parent.$el.getAttribute("thisIsAProp");
  },

0👍

Data can be passed from the the page to entry point either with global variables:

<script>
window.myApp = {
  foo: 'bar'
}
</script>
<div id="app"></div>

And accessed inside the app like window.myApp.foo.

Arbitrary string data (including JSON) can be passed through HTML attributes, data attributes commonly serve this purpose:

<div id="app" data-foo="bar"></div>

And accessed inside the app like document.querySelector('#app').dataset.foo.

Leave a comment