iPhone 6s, running iOS 12.0.1
Plugging the phone into a computer to charge produces an "Unlock iPhone to use accessories" message and the phone refuses to charge.
How do I fix this nonsensical behavior? I know Apple added a privacy feature where the phone disables the data connection on lock to thwart hacktools that plug into the phone and brute-force the access code, but there's no reason to disable charging-only while it's locked. In this particular case, I only need to charge the phone over a computer; it doesn't need data access.
I'd like to avoid having to buy additional hardware such as a separate power-only limited USB cable.