diff options
Diffstat (limited to 'src/tools/math-evaluator/math-evaluator.vue')
-rw-r--r-- | src/tools/math-evaluator/math-evaluator.vue | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/tools/math-evaluator/math-evaluator.vue b/src/tools/math-evaluator/math-evaluator.vue new file mode 100644 index 0000000..26fb6b1 --- /dev/null +++ b/src/tools/math-evaluator/math-evaluator.vue @@ -0,0 +1,38 @@ +<template> + <div> + <n-input + v-model:value="expression" + rows="1" + type="textarea" + placeholder="Your math expression (ex: 2*sqrt(6) )..." + size="large" + autocomplete="off" + autocorrect="off" + autocapitalize="off" + spellcheck="false" + /> + <br /> + <br /> + + <n-card v-if="result !== ''" title="Result "> + {{ result }} + </n-card> + </div> +</template> + +<script setup lang="ts"> +import { evaluate } from 'mathjs'; +import { computed, ref } from 'vue'; + +const expression = ref(''); + +const result = computed(() => { + try { + return evaluate(expression.value) ?? ''; + } catch (_) { + return ''; + } +}); +</script> + +<style lang="less" scoped></style> |