Photocatalytic materials are some of the most promising substitutes for antibiotics. However, the antibacterial efficiency is still inhibited by the rapid recombination of the photogenerated carriers. Herein, we design a cationic covalent organic framework (COF), which has a symmetrical localized built-in electric field due to the induced polarization effect caused by the electron-transfer reaction between the Zn-porphyrin unit and the guanidinium unit. Density functional theory calculations indicate that there is a symmetrical electrophilic/nucleophilic region in the COF structure, which results from increased electron density around the Zn-porphyrin unit. The formed local electric field can further inhibit the recombination of photogenerated carriers by driving rapid electron transfer from Zn-porphyrin to guanidinium under light irradiation, which greatly increases the yield of reactive oxygen species. This COF wrapped by DSPE-PEG2000 can selectively target the lipoteichoic acid of Gram-positive bacteria by electrostatic interaction, which can be used for selective discrimination and imaging of bacteria. Furthermore, this nanoparticle can rapidly kill Gram-positive bacteria including 99.75% of Staphylococcus aureus and 99.77% of Enterococcus faecalis at an abnormally low concentration (2.00 ppm) under light irradiation for 20 min. This work will provide insight into designing photoresponsive COFs through engineering charge behavior.