The application discloses an electronic device, which belongs to the technical field of communication. Wherein, the electronic device includes a housing, a camera module, a first coil and a first magnetic member, the housing is provided with a receiving groove, the receiving groove has an opening communicating with the outside world, the camera module is provided with a camera, and the camera module detachable so as to be switchable between an installed state and a detached state, in which the camera module is installed in the receiving groove; in the detached state, the camera module is separated from the housing , one of the first coil and the first magnetic member is arranged on the housing, and the other is arranged on the camera module, and when the first coil is energized, the The casing and the camera module attract or repel each other, so that the camera module switches between the installed state and the separated state. The solution provided by the present application increases the screen-to-body ratio of the electronic device.