So when Chubby, a 1-year-old Labrador, needs to go out, Mr. Perez pulls on gloves, straps on a mask, and wriggles into the special jacket and pants that are sprayed down with alcohol after every trip outdoors. Then he slides a yellow jacket over Chubby, too.

The State Department has evacuated hundreds of Americans from Hubei Province, where the outbreak began. But some, like Mr. Perez, have decided not to leave. In his case, it is because he does not want to abandon his girlfriend, who is Chinese.

They have spent more than two weeks in his apartment, along with his girlfriend’s brother. They cook, they watch television (three seasons of “The Sopranos” so far), and they clean — a lot. They scrub down surfaces, furiously wash their hands and disinfect their clothes after going out.

“Sometimes I find I’m out of time, which is crazy,” Mr. Perez said. “You’d think I’d have all the time in the world, but with the coronavirus, a lot of time is spent cleaning.”

Other Americans have also stayed in China because of loved ones. Gabrielle Autry, 26, from Georgia, lives in the eastern city of Hangzhou. She has looked into flights that would take her to the United States — but her fiancé, a Chinese citizen, would not be able to join her, since all foreign citizens are barred from entering the United States if they have recently been in China. If the two were married, it would be a different story.

For now, they are mostly stuck at home, a little bored.

“Together it’s O.K., but alone it would be horrible,” she said. “I just couldn’t fathom it.”

Mr. Perez has tried to make the best of the isolation, working on his coding skills and reading news about the virus. He talks to his family nearly every day. His parents have sent him masks.