The invention relates to application of a porous magnesium alloy as a carrier in medicine. Drugs can be carried onto the porous magnesium alloy to be used as a blood vessel stent, bone repair or bone propping material. The porous magnesium alloy is prepared by direct foaming, corrosion pore forming, laser drilling, powder metallurgy, quick forming, co-permeation vibration, 3D printing and the like. Laser cladding, microarc oxidation, anode oxidation, osmosis, embedding, solvent evaporation drying, melting, adsorption equilibrium and the like are performed to carry drugs into the porous magnesium alloy surface or the inside of the porous structure, thereby performing the functions of increasing the surface activity, promoting the bone cell growth and differentiation, preventing infection, implementing specific drug delivery and partial drug delivery and the like. The preparation method is simple to operate and easy to implement, and has the advantages of controllable structure, convenient drug carrying, firm drug combination, low cost and the like.