The invention discloses a refractive index sensor based on a metal nanostructure and single-layer TMDs composite system and a method. According to the invention, a composite structure formed by clinging a metal nanostructure and a single-layer transition metal sulfide is adopted, and a local surface plasmon polariton refractive index sensor which can be almost independently controlled is realizedin a visible light waveband; local surface plasmon of a metal nanostructure and excitons of a TMDs two-dimensional material are fused, and the advantages of the local surface plasmon and the excitonsare combined, so that the extremely good sensing performance is achieved, and the index requirements of a novel sensor can be met; the scattering spectrum is enhanced, so that the effect of enhancingthe signal-to-noise ratio is achieved; and when the external environment changes, the spectral line width is narrowed relative to a single metal nanostructure, and rich structural information is extracted, so that high-sensitivity sensing is realized; the size of the device can be reduced, and the sensor has potential application in a highly integrated local surface plasmon sensor. The refractiveindex sensor has the advantages of simple structure, small volume, high signal-to-noise ratio, high sensitivity and quick response.