第一种 拼接字符串
function getPath (mobile, mobileModel, data){
return data[0].name + '/' + mobile + '/' + mobile + ' ' + mobileModel
}getPath('huawei','mate 20',data)
第二种 使用模板字符串 模板字符串中空格直接 就打一个空格就行
var data =[{"name":"手机","childs":[{"name":"iphone","childs":[{"name":"iphonex"},{"name":"iphonexR"},{"name":"iphonexS"}]},{"name":"HUAWEI","childs":[{"name":"HUAWEIX"},{"name":"HUAWEIxR"},{"name":"HUAWEIxS"}]}]}]functiongetPath(mobile, mobileModel, data){return`${data[0].name}/${mobile}/${mobile}/${mobileModel}`}getPath('huawei','mate 20',data)