oninput 事件里
//先把非数字的都替换掉,除了数字和.
scope.showBuyPrice = scope.showBuyPrice.replace(/[^d.]/g,"");
//必须保证第一个为数字而不是.
scope.showBuyPrice = scope.showBuyPrice.replace(/^./g,"");
//保证只有出现一个.而没有多个.
scope.showBuyPrice = scope.showBuyPrice.replace(/.{2,}/g,".");
//保证.只出现一次,而不能出现两次以上
scope.showBuyPrice = scope.showBuyPrice.replace(".","$#$").replace(/./g,"").replace("$#$",".");
之后怎么写能满足需求呢
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…