The invention discloses a method for preparing composite fibers in an ionic liquid medium. The method comprises the following steps: (1) oxidating cellulose into carboxyl cellulose in an oxidation system prepared from ionic liquid, nitric acid and NaNO2, and preparing a carboxyl cellulose solution; (2) subjecting silkworm cocoons to soda boiling, degumming, LiBr dissolving, dialysis and vacuum freeze drying so as to obtain silk fibroin, and then, preparing a silk fibroin solution in ionic liquid; (3) grafting the carboxyl cellulose to the silk fibroin in ionic liquid, thereby obtaining the composite fibers. According to the method, the ionic liquid serves as a solvent, cellulosic materials and the silkworm cocoons serve as raw materials, the chemical principle of amidation reaction is adopted, the preparation process is simple, the reaction is green, environment-friendly and pollution-free, the ionic liquid solvent can be recovered and reused through rotary-evaporation drying, and the recovery rate reaches 98%. The reaction system only needs an isothermal reaction of 1 to 2 hours, the percentage of grafting of the cellulosic materials reaches 21% to the maximum, and the composite fibers are excellent in mechanical properties, crinkle resistance, wear resistance and hygroscopic property and are degradable and reproducible.