参考

  1. Electron shell 模块

shell 模块提供了集成其他桌面客户端的关联功能

例子——直接访问工程中的文件

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>first electron</title>
</head>
<body>
  <div>
    <a href="https://hbiao68.blog.csdn.net/" id="myBlog" onclick="openBrowserMyBlog(event)">黄彪的博客</a>
  </div>
</body>
<script src="./js/readFile.js"></script>
<script>
// 定制鼠标右键菜单
const {remote, clipboard } = require('electron');
const shell = remote.shell

function openBrowserMyBlog (e) {
  e.preventDefault()
  let aHrefObj = document.querySelector('#myBlog')
  console.log(aHrefObj)
  debugger
  var href = aHrefObj.getAttribute('href')
  shell.openExternal(href)
}
  </script>
</html>

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐