The present invention discloses a compound for treating a respiratory syncytial virus infection and a preparation method and use thereof. The compound is a chemical analogue of cyclopamine and has the properties of inhibiting a replication of a respiratory syncytial virus but not inhibiting a Hedgehog signaling pathway. The preparation method comprises synthesizing a chemical analogue of cyclopamine by pharmaceutical chemistry and screening for an analogue of interest by means of two parallel in vitro assays. The compound can be used to treat a respiratory virus infection, a paramyxovirus infection, a respiratory syncytial virus infection, a capillary bronchitis caused by a respiratory syncytial virus, a pneumonia caused by a respiratory syncytial virus, and a tympanitis caused by a respiratory syncytial virus, The compound does not cause a toxic side effect causing fetal anomaly and addresses a teratogenic effect of cyclopamine, filling a gap in medications for the treatment of respiratory syncytial virus infection, especially for use in pediatrics.