默认功能

electron对于html的a标签渲染是在app内打开
image.png

修改默认功能

  1. <h2> <a id="aHref" href="https://wangenbo.cn">王恩博的博客</a> </h2>
  1. const { shell } = require('electron')
  2. //通过链接打开默认浏览器
  3. var aHref = document.querySelector('#aHref')
  4. aHref.onclick = function(e) {
  5. e.preventDefault()
  6. var href = this.getAttribute('href')
  7. shell.openExternal(href)
  8. }

修改后

image.png