Two dark solitons are considered in a two-component Bose-Einstein condensate with an external magnetic trap, and effects of the trap potential on their dynamics are investigated by the numerical simulation. The results show that the dark solitons attract, collide and repel periodically in two compon