Despite the rapid progress of perovskite solar cells (PSCs) toward commercialization, perovskite layers are unstable and contain toxic lead. Encapsulation represents an efficient strategy for improving the stability of PSCs as well as suppressing lead leakage. However, the damage to encapsulation materials during outdoor applications inevitably deteriorates the packaging effect and increases lead leakage. Here we report a damage perception and rapid self-healing encapsulant consisting of alkoxy polyvinylimidazole bis(trifluoromethanesulphonyl)imide (EP). The dynamic ion aggregates in the encapsulant can easily drive the molecular chain movement of EP, thereby achieving rapid damage repair to maintain device stability and inhibit lead leakage. The damaged cracks of EP completely self-heal within 6 minutes at 50°C. The EP encapsulated devices exhibit a lead sequestration efficiency of more than 99% under poor weather. After 1500 hours of damp heat test and 300 thermal cycles, the EP encapsulated devices retain 95.17 and 93.53% of their initial efficiency, respectively.