In view of the importance of metal coatings, this study addresses the ion concentration of the anti‐corrosive coating's immersion solution. The physical properties of the coating surface, such as molecular characteristics, smoothness, and structural strength, were changed by adding nano‐SiO2 in the immersion solution to formulate the best scheme for anti‐corrosive performance. The composite coating was prepared on the surface of AZ31B magnesium alloy by electroless plating. Besides, the surface coating based on AZ31B substrate has high‐quality corrosion resistance to different types of contaminated media. The experimental results demonstrate that the nanocomposite coating can form an ultrafine particle‐filling effect on the metal surface, which is lower than the drag force of the conventional metal surface. Considering the slip velocity gradient in the contact coating area, we reduce the shear stress and drag force, verifying the nanocomposite coating's effect on reducing the reaction force. The contact angle of water droplets in the composite coating is greater than 158.7°. The study finally verifies that the prepared coating has good self‐cleaning potential which can prevent the corrosion of different polluted media.