A time-frequency resource allocation method, comprising: determining, by a network device, N terminal device types based on a current movement speed of a terminal device within a coverage area, wherein the N terminal device types are in a one-to-one correspondence with N uplink demodulation reference signals, DMRSs, with different time domain densities; classifying, by the network device, available time-frequency resources into N time-frequency resource groups based on the N terminal device types, wherein a first uplink DMRS in the N uplink DMRSs is configured for a first time-frequency resource group in the N time-frequency resource groups; and sending, by the network device, resource indication information to the terminal device based on the N time-frequency resource groups, wherein the resource indication information is used to indicate the N time-frequency resource groups, and N is an integer greater than or equal to 2; wherein the sending, by the network device, resource indication information to the terminal device based on the N time-frequency resource groups comprises: broadcasting, by the network device, the resource indication information by using a physical broadcast channel PBCH; wherein the method further comprises receiving uplink data transmission on a target time-frequency resource in a contention based transmission manner, wherein the target time-frequency resource is a time-frequency resource in a target time-frequency resource group that is corresponding to a terminal device type of the terminal device and that is in the N time-frequency resource groups, and the target time-frequency resource is determined by the terminal device from the target time-frequency resource group through contention. determining, by a network device, N terminal device types based on a current movement speed of a terminal device within a coverage area, wherein the N terminal device types are in a one-to-one correspondence with N uplink demodulation reference signals, DMRSs, with different time domain densities; classifying, by the network device, available time-frequency resources into N time-frequency resource groups based on the N terminal device types, wherein a first uplink DMRS in the N uplink DMRSs is configured for a first time-frequency resource group in the N time-frequency resource groups; and sending, by the network device, resource indication information to the terminal device based on the N time-frequency resource groups, wherein the resource indication information is used to indicate the N time-frequency resource groups, and N is an integer greater than or equal to 2; wherein the sending, by the network device, resource indication information to the terminal device based on the N time-frequency resource groups comprises: broadcasting, by the network device, the resource indication information by using a physical broadcast channel PBCH; wherein the method further comprises receiving uplink data transmission on a target time-frequency resource in a contention based transmission manner, wherein the target time-frequency resource is a time-frequency resource in a target time-frequency resource group that is corresponding to a terminal device type of the terminal device and that is in the N time-frequency resource groups, and the target time-frequency resource is determined by the terminal device from the target time-frequency resource group through contention.