Compare commits

..

No commits in common. 'd223e81d520ef1f22cf41fab7d1b8f521a3f44c3' and '686f3ae0d952be1c1c688615e4fa63dce8ccdb2c' have entirely different histories.

@ -6,9 +6,7 @@
<OperatorButton v-for="op in operators" :key="op.operator" :operator="op.operator" @click="appendOperator(op.operator)" />
<button @click="appendDecimal('.')">.</button>
<button @click="calculate">=</button>
<button @click="deleteLastChar">del</button>
<button class="ac-button" @click="clearDisplay">AC</button>
</div>
</div>
</template>
@ -31,8 +29,6 @@ const operators = [
{ operator: '%' },
];
const appendNumber = (number) => {
if (displayValue.value === '0' || displayValue.value === '表达式错误') {
displayValue.value = number;
@ -51,16 +47,6 @@ const appendOperator = (op) => {
const calculate = () => {
displayValue.value = eval(displayValue.value);
try {
const result = Function('"use strict"; return (' + displayValue.value + ')')();
if (!isFinite(result)) {
displayValue.value = '错误';
} else {
displayValue.value = result;
}
} catch (error) {
displayValue.value = '错误';
}
};
const clearDisplay = () => {
@ -69,12 +55,6 @@ const clearDisplay = () => {
secondNumber.value = null;
operator.value = null;
};
const deleteLastChar = () => {
if (displayValue.value.length > 0) {
displayValue.value = displayValue.value.slice(0, -1); //
}
};
</script>
<style scoped>

Loading…
Cancel
Save