nalinv-mobile/utils/common.js

41 lines
740 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 聚焦输入框,输入框须有ref
* @param me 传入this
* @param ref
*/
export function inputFocus(me, ref) {
try{
me.$nextTick(() => {
if (me.$refs[ref].getFocus instanceof Function) {
me.$refs[ref].getFocus();
} else {
if (me.focus) {
me.focus[ref] = false;
me.$nextTick(() => {
me.focus[ref] = true;
});
}
}
});
}catch(err){
}
}
export function accAdd(arg1, arg2) {
var r1, r2, m;
try {
r1 = arg1.toString().split(".")[1].length;
} catch (e) {
r1 = 0;
}
try {
r2 = arg2.toString().split(".")[1].length;
} catch (e) {
r2 = 0;
}
m = Math.pow(10, Math.max(r1, r2));
return (arg1 * m + arg2 * m) / m;
}