您可以使用padStart()https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart/*"000000" should equal to "000001""000100" should equal to "000101""000009" should equal to "000010"*/const a = "000000";const b = "000100";const c = "000009";console.log((Number(a)+1).toString().padStart(6,"0"));console.log((Number(b)+1).toString().padStart(6,"0"));console.log((Number(c)+1).toString().padStart(6,"0"));