js小数四舍五入,保留两位小数
直接用用number.toFixed(2)即可
<template>
<section class="p-10">
<h1> {{ number }} </h1>
</section>
</template>
<script>
export default {
data() {
return {
number: 3.1415926
};
},
created() {
this.number = this.number.toFixed(2);
}
}
</script>
<style lang="scss">
</style>
嗯,就酱~~