The utility model discloses a
camera module and an electronic device, and the
camera module is used for improving the
imaging quality. The lens
assembly comprises a lens base, a lens, a guide part and a driving part, the guide part is connected with the mounting base and extends in the
optical axis direction of the lens, the lens base and the guide part are slidably connected in the
optical axis direction of the lens, the lens is mounted on the lens base, and the driving part is arranged on the mounting base, connected with the lens base and used for driving the lens base to slide; the protection
assembly comprises a supporting seat, a light-transmitting part and an elastic part, the supporting seat and the lens seat are in sliding connection in the
optical axis direction of the lens, the supporting seat is provided with a light-transmitting hole and a mounting groove, the light-transmitting hole penetrates through the supporting seat in the optical axis direction of the lens, the lens is contained in the light-transmitting hole, and the mounting groove is formed in the side, away from the lens seat, of the supporting seat and communicates with the light-transmitting hole; the light-transmitting part is mounted in the mounting groove, the guide part is sleeved with the elastic part, and the two ends of the elastic part abut against the lens base and the supporting base respectively; and the heating piece is arranged in the mounting groove, is positioned between the lens and the light-transmitting piece and is used for heating the light-transmitting piece.