接上
https://blog.csdn.net/milijiangjun/article/details/108647262
正则 下横线转驼峰式:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript">
function toCamel(str) {
return str.replace(/([^_])(?:_+([^_]))/g, function ($0, $1, $2) {
return $1 + $2.toUpperCase();
});
}
console.log(toCamel('test_to_camel')); //testToCamel
</script>
</head>
<body>
</body>
</html>