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>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue';
|
||||
import katex from 'katex';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
formula: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
block: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
compiledFormula(): any {
|
||||
return katex.renderToString(this.formula, {
|
||||
throwOnError: false,
|
||||
} as any);
|
||||
},
|
||||
},
|
||||
});
|
||||
const props = defineProps<{
|
||||
formula: string;
|
||||
block: boolean;
|
||||
}>();
|
||||
|
||||
const compiledFormula = computed(() => katex.renderToString(props.formula, {
|
||||
throwOnError: false,
|
||||
}));
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
|
Loading…
Reference in a new issue