Wells has povi; havi la rimedojn por, toleri la elspezon por; doni (well, it actually has espezon, but that's a typo). The third meaning (as in The Sun affords warmth to the Earth) does not concern us here.

Povi (“to be able”) is indeed the good, basic translation I would teach to beginners. I have upvoted Lyubomir's answer proposing it. However, proficient Esperanto speakers might want to express themselves in a more articulate manner. They’d use different idioms in different situations, without caring about how they relate to similar English idioms.

Havi la rimedojn por (“to have the means to”) is just one such idiom, perhaps the clearest of all. I have no problems with it, and I’m sure I’ve used it many times. It gets thousands of Google hits and John is right in suggesting it to his readers. However, it’s a bit too specific, and it doesn’t work in all cases. “They can’t afford losing more time” could be about money, but it’s usually about hopes of achieving a result. Similarly “our team can’t afford to lose the match” might be about sponsors, but it’s usually about championship prospects. And if “savvy marketers can’t afford to ignore the opportunities of international marketing”, they usually do have the means, but the sentence says something different.

Without any doubt I am influenced by my native Italian, but in my opinion a general solution is provided by povi permesi al si:

Mi pensas, ke mi povas permesi al mi novan komputilon.

Ni ne povas permesi al ni maltrafi tiun eblecon.

Ili ne povas permesi al si perdi plian tempon.

and more:

Nia teamo ne povas permesi al si malgajni la matĉon.

Lertaj merkatistoj ne povas permesi al si neglekti la eblecojn de internacia surmerkatigo.

This particular use of povi permesi al si, a small fraction of the overall usage of permesi, is supported by several examples from the Tekstaro:

(I have intentionally omitted Italians and Frenchmen, who might be as biased as I am. In 1999, Anna Löwenstein had already been living in Italy for many years, but she is a native English speaker and a successful writer: her prose cannot be dismissed.)

And from other places:

Wikipedia and Tatoeba contributors are often more enthusiast than competent, but, even if these sites can’t be considered authoritative, they show how Esperanto is used “in the wild” and they are interesting for this reason.

In a previous version of this answer I have dismissed a possible confusion between this meaning and other meanings of permesi al si. In reality, it’s a continuum: while English native speakers know where “to afford” ends and “to allow oneself” begins, not to speak of “to take the liberty” further across the spectrum, those living in languages with less distinctions might make mistakes: it happened to me in the previous version of this answer, where I cited Ni estis tro noblaj por permesi al ni tiajn pensojn, which, as Tomaso points out, has nothing to do with “afford”.

This might explain why PIV mentions permesi al si as “to allow oneself”, with no hint at “to afford”. In French pouvoir se permettre is very common in the sense of “to afford”: a simple se permettre d’acheter (“afford to buy”), no conjugation, only one following verb, gets more than a hundred thousand google hits; however, the extensive monolingual dictionary Petit Robert doesn’t consider this something different from “to allow oneself” and doesn’t deal with it separately. PIV, which was written by Frenchmen and whose definitions are often very similar to those of Petit Robert, apparently did the same.

My point is that even if, in English, “to allow oneself” has no implication of serious detriment or financial hardship, povi permesi al si does have it: Z and other good writers used it with this meaning; speakers of French, Spanish, Italian and probably other languages recognize what they have in their languages and follow happily; maybe they are wrong because this pattern seems not to be international enough. I’d rather let the speaker community as a whole decide. As it always happens in an international setting, one thing which is obvious for some isn’t obvious at all for others: it is important to acknowledge such differences. As time passes, consensus tends to emerge.

I want to add that John Wells’ final suggestion, toleri la elspezon, as well as Tomaso’s elteni la elspezon/la perdon, are also very good in many cases. Where I come from, “to endure the expense” and “to afford” have different connotations, but I can ignore the difference in Esperanto.

In negative sentences, however, I see a problem. Mi ne povas elteni lin is the normal translation of “I can’t stand him”. In a world where you cannot use permesi al si, the sentence mi ne povas elteni krompagojn is genuinely ambiguous. Does it mean that you cannot afford additional expenses, or that you cannot stand being asked for one? I would say that it means the latter, because I would use mi ne povas permesi al mi krompagojn for the former. In a borderline case like this one, to be understood by everybody, I’d settle for mi ne havas monon por krompagoj for the former and mi ne povas elteni krompago-petadon for the latter.