Republican presidential candidate Donald Trump has said he will accept the result of the US election, but only if he wins.