qfw
This commit is contained in:
40
lib/index.js
40
lib/index.js
@@ -11198,10 +11198,32 @@ const _sfc_main$1v = defineComponent({
|
||||
});
|
||||
const isPassword = computed$1(() => type4.value == "password");
|
||||
const composing = ref(false);
|
||||
const formatMoney = function(s) {
|
||||
var noNegative = true;
|
||||
s = parseFloat((s + "").replace(/[^\d\.-]/g, "")) + "";
|
||||
if (parseFloat(s) < 0) {
|
||||
s = Math.abs(s).toFixed(2) + "";
|
||||
noNegative = false;
|
||||
}
|
||||
var l = s.split(".")[0].split("").reverse(), r = s.split(".")[1];
|
||||
var t = "";
|
||||
for (let i = 0; i < l.length; i++) {
|
||||
if (i % 3 == 2 && i != l.length - 1) {
|
||||
t += l[i] + ",";
|
||||
} else {
|
||||
t += l[i] + "";
|
||||
}
|
||||
}
|
||||
return (noNegative ? "" : "-") + t.split("").reverse().join("") + "." + r;
|
||||
};
|
||||
watch(() => props.type, () => {
|
||||
type4.value = props.type;
|
||||
});
|
||||
watch(() => props.modelValue, () => {
|
||||
if (props.qfw) {
|
||||
currentValue.value = formatMoney(props.modelValue.toString());
|
||||
return;
|
||||
}
|
||||
currentValue.value = String(props.modelValue == null ? "" : props.modelValue);
|
||||
});
|
||||
const onInput = function(event) {
|
||||
@@ -11236,24 +11258,6 @@ const _sfc_main$1v = defineComponent({
|
||||
onNumberBlur(event);
|
||||
}
|
||||
if (props.qfw) {
|
||||
var formatMoney = function(s) {
|
||||
var noNegative = true;
|
||||
s = parseFloat((s + "").replace(/[^\d\.-]/g, "")) + "";
|
||||
if (parseFloat(s) < 0) {
|
||||
s = Math.abs(s).toFixed(2) + "";
|
||||
noNegative = false;
|
||||
}
|
||||
var l = s.split(".")[0].split("").reverse(), r = s.split(".")[1];
|
||||
var t = "";
|
||||
for (let i = 0; i < l.length; i++) {
|
||||
if (i % 3 == 2 && i != l.length - 1) {
|
||||
t += l[i] + ",";
|
||||
} else {
|
||||
t += l[i] + "";
|
||||
}
|
||||
}
|
||||
return (noNegative ? "" : "-") + t.split("").reverse().join("") + "." + r;
|
||||
};
|
||||
try {
|
||||
let reg = /\d{1,3}(?=(\d{3})+$)/g;
|
||||
console.log("\u6DFB\u52A0\uFF0C", formatMoney(props.modelValue.toString()));
|
||||
|
||||
Reference in New Issue
Block a user