An electronic device comprising a first main body, a second main body, and a rotating shaft mechanism, wherein the rotating shaft mechanism comprises a rotating shaft base, a first rotating member, a second rotating member, and a linkage assembly, and the first rotating member is connected with the first main body and the second rotating member is connected with the second main body; and the linkage assembly comprises a first linkage member and a second linkage member, the first linkage member and the second linkage member are each rotatably connected with the rotating shaft base, the first linkage member has a first sliding block, the second linkage member has a second sliding block, the first rotating member has a first sliding portion in sliding fit with the first sliding block, the second rotating member has a second sliding portion in sliding fit with the second sliding block; wherein the first rotating member has a first rotating portion, the first rotating portion is rotatably connected with the rotating shaft base, the first rotating portion and the first sliding portion are arranged side by side in a direction of a rotation axis-line of the first linkage member, and an orthographic projection of the first linkage member on a plane where the first rotating portion is located at least partially falls into the first rotating portion, and an orthographic projection of the first sliding portion on the plane where the first rotating portion is located at least partially falls into the first rotating portion; wherein the second rotating member has a second rotating portion, the second rotating portion is rotatably connected with the rotating shaft base, the second rotating portion and the second sliding portion are arranged side by side in a direction of a rotation axis-line of the second linkage member, and an orthographic projection of the second linkage member on a plane where the second rotating portion is located at least partially falls into the second rotating portion, and an orthographic projection of the second sliding portion on the plane where the second rotating portion is located at least partially falls into the second rotating portion. the rotating shaft mechanism comprises a rotating shaft base, a first rotating member, a second rotating member, and a linkage assembly, and the first rotating member is connected with the first main body and the second rotating member is connected with the second main body; and the linkage assembly comprises a first linkage member and a second linkage member, the first linkage member and the second linkage member are each rotatably connected with the rotating shaft base, the first linkage member has a first sliding block, the second linkage member has a second sliding block, the first rotating member has a first sliding portion in sliding fit with the first sliding block, the second rotating member has a second sliding portion in sliding fit with the second sliding block; wherein the first rotating member has a first rotating portion, the first rotating portion is rotatably connected with the rotating shaft base, the first rotating portion and the first sliding portion are arranged side by side in a direction of a rotation axis-line of the first linkage member, and an orthographic projection of the first linkage member on a plane where the first rotating portion is located at least partially falls into the first rotating portion, and an orthographic projection of the first sliding portion on the plane where the first rotating portion is located at least partially falls into the first rotating portion; wherein the second rotating member has a second rotating portion, the second rotating portion is rotatably connected with the rotating shaft base, the second rotating portion and the second sliding portion are arranged side by side in a direction of a rotation axis-line of the second linkage member, and an orthographic projection of the second linkage member on a plane where the second rotating portion is located at least partially falls into the second rotating portion, and an orthographic projection of the second sliding portion on the plane where the second rotating portion is located at least partially falls into the second rotating portion.