url中不能带有中文, 所有在url中拼接字符串的时候, 要先对中文进行编码
encodeURI() 函数可以把字符串作为uri编码
let cityName = encodeURI('武汉')
fetch(`http://v.juhe.cn/weather/index?&cityname=${cityName}`)
如果遇到以下报错 , 可能原因就是这个
url中不能带有中文, 所有在url中拼接字符串的时候, 要先对中文进行编码
encodeURI() 函数可以把字符串作为uri编码
let cityName = encodeURI('武汉')
fetch(`http://v.juhe.cn/weather/index?&cityname=${cityName}`)
如果遇到以下报错 , 可能原因就是这个