How to solve the flicker caused by repainting after canvas emptying the canvas

if there is content on the canvas canvas, use clearRect to empty the canvas and redraw it, which will cause the page to flicker visually
how to solve

Dec.18,2021
Menu