extractUrls(text) {
const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/gi
if (text && text.match(urlRegex)) {
const urls = text.match(urlRegex)[0]
return text.replace(urls, `<span style="color:#4670e8">${urls}</span>`)
}
}
js 识别链接 添加样式
最新推荐文章于 2024-07-06 16:47:02 发布