The invention discloses a method for in-situ doping of thin film materials. Elements which can be doped comprise selenium (Se), sodium (Na), sulfur (S), tin (Sn), indium (In), antimony (Sb), gallium (Ga), tellurium (Te), molybdenum (Mo), and arsenic (As). According to the invention, ligands containing the elements are connected onto the surfaces of semiconductor nanoparticles and applied onto the surface of a substrate, and then the nanoparticles are recrystallized by annealing to form a thin film. Thus, the in-situ doping of the elements is realized. For CIGS nanoparticles, concrete in-situ doping working procedures are invented, comprising ligand synthesis and exchange; and direct doping and indirect doping are selected on account of different materials. In this way, the in-situ doping of the CIGS nanoparticles in a controllable doping ratio is realized (in the figure, the element X stands for one or more selected from the group consisting of selenium (Se), sodium (Na), sulfur (S), tin (Sn), indium (In), antimony (Sb), gallium (Ga), tellurium (Te), molybdenum (Mo), and arsenic (As)).