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

135
Vistas
External javascript from public/index.html not loading in Vue component

I want to use Mathjax on my website. I put in the <head> section of public/index.html:

<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

And, in my component :

<template>
    <div v-html="note_content"></div>
</template>

<script>
import { typeset, dummy_typeset } from '../assets/js/text_processing.js';
import showdown from 'showdown';

const converter = new showdown.Converter({ tables: true });

export default {
    data () {
        return {
        }
    },
    computed: {
        note_content: function() {
            return typeset(this.exchange_data);
        }
    },
    props: ['exchange_data'],
    watch: {
        note_content: function() {
            Mathjax.typesetPromise();
        }
    }
}
</script>

However on runtime, I get the error :

Uncaught (in promise) ReferenceError: Mathjax is not defined

What I do not understand is that the css which is located in the head of public/index.html is correctly loaded and rendered in the component. Also I read elsewhere that loading external javascript this way should make it available to all components. What is wrong ?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I think it is connected to webpack config, but i might be wrong. Anyway, have you tried this method?

How to add external JS scripts to VueJS Components?

It enforces the script to be loaded.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Contrarily to what is written at https://docs.mathjax.org/en/latest/web/typeset.html, the syntax for asynchronous rendering is not :

Mathjax.typesetPromise()

But (notice the case):

MathJax.typesetPromise()

The typo could be detected from the surrounding context.

Also not that to use typeset Mathjax in a Vue component, the virtual DOM should be processed before calling the typesetPromise method, so an example of working code would be:

watch: {
    note_content: function() {
        this.$nextTick(MathJax.typesetPromise);
    }
}
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