Imagine your old phone dissolving away after you’ve traded up, or a pacemaker that’s absorbed by the body when it’s no longer needed. Such gadgetry may not be far off: Scientists have developed a technique for making electronic devices that disappear without a trace. Constructed of silicon, magnesium and silk, the transient electronics can be tuned to last for days, weeks or even a year — and then disappear.

Scientists used the approach to make a bacteria-fighting medical implant that melts...