refactor: formula-core.vue to composition api

This commit is contained in:
Norm 2022-08-19 16:02:51 -04:00
parent b3b8e56092
commit e8414e8c8d
Signed by untrusted user: norm
GPG key ID: 7123E30E441E80DE

View file

@ -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>