The invention discloses a photoelectrochemical sensor preparation method based on efficient and stable in-situ growth of a titanium dioxide/nanogold photo-anode. The preparation method comprises the following steps: cleaning ITO (indium tin oxide) slices of an indium tin oxide electrode; sequentially putting the ITO slices into acetone, ethanol and an ultrapure water solution for ultrasonic treatment; wiping with an ethanol cotton ball, washing with ultrapure water, annealing in a culture dish with one side of ITO upward, taking out the ITO slices, and carrying out plasma and ozone treatment;spin-coating a tetraisopropyl titanate, butyl titanate or ethyl titanate precursor on the treated ITO slices, and then annealing a spin-coated ITO substrate to obtain an ITO/TiO2 electrode; and cooling the ITO/TiO2 electrode to room temperature, and carrying out in-situ gold nanoparticle loading to obtain an ITO/TiO2/Au NPs photo-anode. The photoelectrochemical sensor has the advantages of being efficient, uniform, stable, high in preparation repeatability, simple in structure, good in storage stability, good in detection repeatability, sensitive to miRNA-21, specific to miRNA-21 and the like,and is used for detecting miRNA.