第一种:
第二种: 正则匹配
let a = 'https://cnblogs.com/posts/edit' let b = /^http(s)?:\/\/(.*?)\//console.log(b.exec(a)[2])// cnblogs.com