The present invention provides a class of indolizine compounds represented by formula (I), pharmaceutically acceptable salts thereof, a preparation method thereof, and a use thereof. The indolizine compounds have an inhibitory effect on wild-type and/or mutant EZH2 or EZH1 and have good prospects as a novel anti-tumor drug or a drug for treatment of autoimmune diseases.