mathlive在vue中使用

 

<template>
  <div>
    <math-field
      id="formula"
      virtual-keyboard-mode="manual"
      style="padding: 1px; margin: 10px"
      >x=\frac{-b\pm \sqrt{b^2-4ac}}{2a}</math-field
    >
    <el-input
      type="textarea"
      :value="mathText"
      @input="handleMathInput"
    ></el-input>
  </div>
</template>

<script>
import { MathfieldElement } from "mathlive";
let mf;
export default {
  data() {
    return {
      mathText: "",
    };
  },
  mounted() {
    mf = document.querySelector("#formula");
    const updateLatex = () => {
      this.mathText = mf.value;
    };
    mf.addEventListener("input", updateLatex);
  },

  methods: {
    handleMathInput(value) {
      mf.setValue(value);
      this.mathValue = value;
    },
  },
};
</script>

<style></style>

猜你喜欢

转载自blog.csdn.net/xutongbao/article/details/125432142