A semiconductor laser, comprising a substrate and a layer body, wherein the layer body comprises a lower waveguide layer, a lower confining layer, a central layer, an upper confining layer, a grating layer, an upper waveguide layer, and a first electrode layer that are sequentially formed on the substrate in a preset direction; the preset direction is a direction from an end close to the substrate to an end away from the substrate; the layer body is divided into a laser region, a first isolation region, and a filtering region in a cavity length direction; the first isolation region is located between the laser region and the filtering region, and the first isolation region comprises a groove formed by etching the first electrode layer; the first electrode layer in the laser region is configured to receive a first electrical excitation signal; the upper confining layer, the central layer, and the lower confining layer in the laser region form an active layer of the laser region, to generate and transmit an optical signal under an action of the first electrical excitation signal; and the upper confining layer, the central layer, and the lower confining layer in the filtering region form a core layer of the filtering region, to transmit a filtered optical signal; the grating layer in the laser region comprises a Bragg grating, and the Bragg grating is configured to select a single longitudinal mode; and the grating layer in the filtering region comprises a slanted grating, and the slanted grating is configured to perform optical filtering; wherein the Bragg grating is a phase-shifted grating with a phase shift of λ/4, wherein λ is a lasing wavelength of the laser region; and wherein the slanted grating is a uniform grating with a preset slant angle, and wherein the preset slant angle of the slanted grating is measured relative to a plane perpendicular to a waveguide direction, wherein the waveguide direction is parallel to the cavity length direction, and wherein the preset slant angle is any angle from 2° to 10°. the first electrode layer in the laser region is configured to receive a first electrical excitation signal; the upper confining layer, the central layer, and the lower confining layer in the laser region form an active layer of the laser region, to generate and transmit an optical signal under an action of the first electrical excitation signal; and the upper confining layer, the central layer, and the lower confining layer in the filtering region form a core layer of the filtering region, to transmit a filtered optical signal; the grating layer in the laser region comprises a Bragg grating, and the Bragg grating is configured to select a single longitudinal mode; and the grating layer in the filtering region comprises a slanted grating, and the slanted grating is configured to perform optical filtering; wherein the Bragg grating is a phase-shifted grating with a phase shift of λ/4, wherein λ is a lasing wavelength of the laser region; and wherein the slanted grating is a uniform grating with a preset slant angle, and wherein the preset slant angle of the slanted grating is measured relative to a plane perpendicular to a waveguide direction, wherein the waveguide direction is parallel to the cavity length direction, and wherein the preset slant angle is any angle from 2° to 10°.