我正面临这个错误:
Uncaught Error :尚未为上下文加载模块名称“Electron ”:_。使用要求([])
$scope.sendWhatsapp = function (report) {
let url = 'https://wa.me/91' + report.patient_phone_no + '?text=Hi, Your report is ready. Please visit the laboratory to collect it.'
console.log(typeof window.require);
if (typeof window.require === 'function') {
const shell = window.require('electron')
shell.openExternal(url);
}
}
提前致谢
最佳答案
只需设置一个全局变量并在 Angular 组件中访问它
**main.js**
app.whenReady().then(() => {`
let mainWindow = new BrowserWindow({`
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
contextIsolation: true
},
width:640,
height: 480,
resizable: false
})
... rest of code
**preload.js**
const { contextBridge, shell} = require('electron')
contextBridge.exposeInMainWorld(
'electron',
{
shell: shell
})
关于angularjs - Uncaught Error : Module name "electron" has not been loaded yet for context: _. 使用 require([]),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66505501/