In this work, a novel near-infrared fluorescent probe of benzopyranonitrile toward β-Gal was developed with high selectivity and low detection limits. DCM-Mor-Gal could effectively distinguish hepatocellular cells (HepG2) from SGC7901, HeLa, A549, and human normal liver cells (HL-7702) under the mediation of the galactose group, and effectively aggregate in the lysosomes under the acidity-alkalinity attraction, showing a notable dual-targeting potential of hepatocytes and lysosomes. The zebrafish experiments confirmed the utility of DCM-Mor-Gal in detecting β-Gal in vivo, which is expected to be an effective tool for the clinical detection of related diseases.