Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
Am I able to use properties on the index.html file on the vuejs mount element?
<!DOCTYPE html>
<html lang="">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
    <title><%= htmlWebpackPlugin.options.title %></title>
  </head>
  <body>
    <noscript>
      <strong
        >We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work
        properly without JavaScript enabled. Please enable it to
        continue.</strong
      >
    </noscript>
    <div id="app" thisIsAProp="This is what I need"></div>
    <!-- built files will be auto injected -->
  </body>
</html>

So in my main.js file the app is mounted on #app. In my App.js file I need the properties on the <div id="app"> element. I tried using web-components which did work for a basic app but another requirement is I need to be able to overwrite the CSS variables within the parent web page, and when creating web components, vue creates them with a shadow-dom. Is there a better way to get the values from the vue mount element?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

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.

about 4 years ago · Juan Pablo Isaza Report

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");
  },
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!