Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda