It has been widely recognized that efficient approaches to water–oil separation need to be developed and designed. It is the objective of this study to improve and optimize the performance of g-C3N4 for oil–water separation by anchoring Zn(OH)2. Additionally, the as-prepared g-C3N4/Zn(OH)2 nanocomposites containing different amounts of Zn(OH)2 were investigated to determine the effect of two factors of porosity and surface defects in the water-removing of oil–water mixtures. The results show that oxygen-containing groups in this specific g-C3N4/Zn(OH)2 nanocomposite have a greater impact on wettability behavior and water-removing separation performance than porosity. Density functional theory (DFT) calculations demonstrated that the adsorption energy of water is larger than that of oil molecules on the g-C3N4/Zn(OH)2, confirming that the prepared coated mesh can be used as a potential material for water–oil separation. Moreover, the self-cleaning property of the nanocomposite-coated mesh was demonstrated by the removal of adsorbed oil in contact with the surface. In this study, it was also attempted to perform water and oil separation with good performance. Therefore, the perfluorooctanoic acid (PFOA) was also used to reduce energy in g-C3N4@Zn(OH)2@PFOA mesh, leading to super-hydrophilic/super-oleophobic wettability. Ultimately, a new mesh coated with g-C3N4@Zn(OH)2@PFOA nanocomposite was successfully separated oil-in-water emulsion with a high efficiency of 99.99%.