<template>
  <div class="MathJax" ref="MathJax" v-html="formula"></div>
</template>

<script>
import Vue from 'vue'
import mathJax from './index'
Vue.prototype.mathJax = mathJax

export default {
  name: 'MathJax',
  props: {
    formula: {}
  },
  components: {},
  data() {
    // 这里存放数据
    return {
      text: ''
    }
  },
  mounted() {},
  watch: {
    formula: {
      handler() {
        this.init()
      },
      deep: true,
      immediate: true
    }
  },
  methods: {
    init() {
      if (this.mathJax.isMathjaxConfig) {
        // 判断是否初始配置，若⽆则配置。
        this.mathJax.initMathjaxConfig()
      }
      this.mathJax.TypeSet(this.$refs.MathJax)
    }
  }
}
</script>

<style lang="scss">
@import './index.scss';
</style>
