
本文共 2730 字,大约阅读时间需要 9 分钟。
������ES6������������������������������
���������������������������������������������Input���������������������������������������������������������������Input���value������string������������������������������������������parseInt���������������������������������������������������������������������parseInt���������������������������������������������������������������������������������������������������������������������������parseFloat���������������������number���������������������������������������parseFloat������������������������������string������������������������������������������������������������������������������������������������������
���������������������������������������������������������������value���������number������������������������������������������
���������������������input������������������������������������������������������������������������������������������������������������������������������������
���������������������������������
const reg = /^-?(0|[1-9][0-9])(.[0-9])?$/;
������������������������������
- ���������������������������������������0������������������������������������������������������������
- ���������������������������������������
- ���������������������������������������������������������������
���������������������
totalPrice = Number.parseFloat(num) * Number.parseFloat(price).toFixed(2);
���������value������������������������������������
- typeof price => string
- typeof parseFloat(price) => string
- typeof Number.parseFloat(price) => number
- typeof totalPrice => number
- typeof totalPrice.toFixed(2) => string
- typeof Number.parseFloat(totalPrice.toFixed(2)) => number
������������������������������������������������������������������������tprice���
const tprice = Number(price) * Number(num).toFixed(2); totalPrice = Number(tprice.toFixed(2));
���������������������������������������������������������������������������
���������������������������������������
������������������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
