forked from FoundKeyGang/FoundKey
refactor: formula-core.vue to composition api
This commit is contained in:
parent
b3b8e56092
commit
e8414e8c8d
1 changed files with 10 additions and 21 deletions
|
@ -4,29 +4,18 @@
|
||||||
<span v-else v-html="compiledFormula"></span>
|
<span v-else v-html="compiledFormula"></span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent } from 'vue';
|
import { computed } from 'vue';
|
||||||
import katex from 'katex';
|
import katex from 'katex';
|
||||||
|
|
||||||
export default defineComponent({
|
const props = defineProps<{
|
||||||
props: {
|
formula: string;
|
||||||
formula: {
|
block: boolean;
|
||||||
type: String,
|
}>();
|
||||||
required: true,
|
|
||||||
},
|
const compiledFormula = computed(() => katex.renderToString(props.formula, {
|
||||||
block: {
|
throwOnError: false,
|
||||||
type: Boolean,
|
}));
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
compiledFormula(): any {
|
|
||||||
return katex.renderToString(this.formula, {
|
|
||||||
throwOnError: false,
|
|
||||||
} as any);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
Loading…
Reference in a new issue