What is claimed is:1. A locking device for locking a first housing to a second housing, the locking device comprising:a first locking member positioned at the first housing and comprising a clamping portion, one end of the clamping portion defining a latching slot; anda second locking member positioned at the second housing, one end of the second locking member forming a locking portion matching the latching slot;wherein when the first locking member is operated, the locking portion is latched to the latching slot, the first locking member is locked to the second member; andwherein when the latching slot is detached from the locking portion in a predetermined direction, the first locking member and the second locking member are unlocked;wherein the clamping portion comprises a receiving portion and a button portion, one end of the receiving portion defines the latching slot, the button portion is positioned at another end of the receiving portion, the latching slot moves relative to the locking portion by pressing the button portion; when the button portion is operated, the receiving portion and the latching slot moves along a same direction, the receiving portion rotates for driving the latching slot to detach from the locking portion.2. The locking device of claim 1, wherein the first locking member further comprises a connecting portion, the connecting portion is fixed to the first housing and is connected to the clamping portion.3. The locking device of claim 2, wherein one side of the connecting portion defines a through groove, the through groove is configured to receiving the receiving portion.4. The locking device of claim 3, wherein the connecting portion is bent to two sides away from the through groove and forms at least one fixing portion at the bending portion, the connecting portion is fixed to the first housing through the at least one fixing portion.5. The locking device of claim 3, wherein two sides of one end of the receiving portion adjacent to the button portion extend along a direction away from the connecting portion and defines a first hinge hole, a side wall of the through groove defines a second hinge hole, the second hinge hole corresponds to the first hinge hole, a hinge shaft sleeved with a torsion spring passes through the second hinge hole and the first hinge hole, the clamping portion is rotatably connected to the connecting portion.6. The locking device of claim 1, wherein the first housing defines a through hole, the button portion is exposed from the through hole.7. The locking device of claim 1, wherein when the first housing provided with the first locking member moves toward the second housing until the latching slot is positioned corresponding to the locking portion, the first locking member is pressed, the locking portion is locked to the latching slot and the first housing is locked to the second housing.8. The locking device of claim 1, wherein when the button portion is pressed, the latching slot is detached from the locking portion, the first housing is dragged to move along a direction away from the second housing, the first housing and the second housing are unlocked.9. A server cabinet comprising:a first housing;a second housing; anda locking device comprising:a first locking member positioned at the first housing and comprising a clamping portion, one end of the clamping portion defining a latching slot; anda second locking member positioned at the second housing, one end of the second locking member forming a locking portion matching the latching slot;wherein when the first locking member is operated, the locking portion is latched to the latching slot, the first locking member is locked to the second member; andwherein when the latching slot is detached from the locking portion in a predetermined direction, the first locking member and the second locking member are unlocked;wherein the clamping portion comprises a receiving portion and a button portion, one end of the receiving portion defines the latching slot, the button portion is positioned at another end of the receiving portion, the latching slot moves relative to the locking portion by pressing the button portion; when the button portion is operated, the receiving portion and the latching slot moves along a same direction, the receiving portion rotates for driving the latching slot to detach from the locking portion.10. The server cabinet of claim 9, wherein the first locking member further comprises a connecting portion, the connecting portion is fixed to the first housing and is connected to the clamping portion.11. The server cabinet of claim 10, wherein one side of the connecting portion defines a through groove, the through groove is configured to receiving the receiving portion.12. The server cabinet of claim 11, wherein the connecting portion is bent to two sides away from the through groove and forms at least one fixing portion at the bending portion, the connecting portion is fixed to the first housing through the at least one fixing portion.13. The server cabinet of claim 11, wherein two sides of one end of the receiving portion adjacent to the button portion extend along a direction away from the connecting portion and defines a first hinge hole, a side wall of the through groove defines a second hinge hole, the second hinge hole corresponds to the first hinge hole, a hinge shaft sleeved with a torsion spring passes through the second hinge hole and the first hinge hole, the clamping portion is rotatably connected to the connecting portion.14. The server cabinet of claim 9, wherein the first housing defines a through hole, the button portion is exposed from the through hole.15. The server cabinet of claim 9, wherein when the first housing provided with the first locking member moves toward the second housing until the latching slot is positioned corresponding to the locking portion, the first locking member is pressed, the locking portion is locked to the latching slot and the first housing is locked to the second housing.16. The server cabinet of claim 9, wherein when the button portion is pressed, the latching slot is detached from the locking portion, the first housing is dragged to move along a direction away from the second housing, the first housing and the second housing are unlocked.