A Vue.js Plugin for Mathjax
-
This is a plugin for vue2, if you are looking for vue3, maybe you can check this
-
This plugin is not compatible with MathJax@3, you can make a PR if you know how to do it.
npm install --save vue-mathjax
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-AMS_HTML"></script>
import VueMathjax from 'vue-mathjax'
Vue.use(VueMathjax)
OR
import {VueMathjax} from 'vue-mathjax'
export default {
...
components: {
'vue-mathjax': VueMathjax
},
...
<template>
<div>
<textarea v-model="formula" cols="30" rows="10"></textarea>
<vue-mathjax :formula="formula"></vue-mathjax>
</div>
</template>
<script>
<!-- You can also define globally -->
import { VueMathjax } from 'vue-mathjax'
export default {
components: {
'vue-mathjax': VueMathjax
},
name: 'HelloWorld',
data () {
return {
formula: '$$x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}.$$',
msg: 'Welcome to Your Vue.js App'
}
}
}
</script>
type: string
mathjax string
type: boolean; default: true
sometimes you want render the html in your mathjax, so just set it to false. demo: https://codesandbox.io/s/vue-template-ftd5s
type: object; default: {}
custom configurations