The invention discloses a composite material and a preparation method thereof. The preparation method comprises the following steps: S1, preparing a metal ion solution with a concentration of 0.01 to 1 mol / L, adding a complexing agent and a nucleating agent, regulating a pH value to be 10.0 to 13.5 by virtue of an alkaline solution, and preparing a solution A, wherein the metal ions are magnetic metal ions or a mixture of magnetic metal ions and nonmagnetic metal ions; S2, preparing 0.1 to 3 mol / L of reducing agent solution with strong reducing property, regulating the pH value of the alkaline solution to be 10.0 to 13.5, and preparing a solution B; S3, sufficiently mixing the solution A and the solution B, reacting at 50 to 100 DEG C and under a magnetic field condition of 0.005 to 1T, , ending the reaction before the agglomeration phenomenon, and preparing a reaction stock solution containing magnetic nanowires or alloy nanowires; and S4, compounding the reaction stock solution prepared in step S3 and a polymer. The preparation method is simple in preparation process, and the prepared composite material has the characteristics of excellent performance and low cost.