Href without http(s) prefix

后端 未结 4 1646
死守一世寂寞
死守一世寂寞 2020-12-29 21:22

I just have created primitive html page. Here it is: example And here is its markup:

www.google.com

&l
4条回答
  •  盖世英雄少女心
    2020-12-29 22:03

    I've created a little function in React project that could help you:

    const getClickableLink = link => {
        return link.startsWith("http://") || link.startsWith("https://") ?
          link
          : `http://${link}`;
      };
    

    And you can implement it like this:

    const link = "google.com";
    {link}
    

提交回复
热议问题