美文网首页
electron的webview中注入js-back

electron的webview中注入js-back

作者: 苏本的书柜 | 来源:发表于2020-07-28 20:37 被阅读0次

将文件读取到字符串并执行它

//myApp.isPacked 用来判断是否是打包,打包之后路径引入需要更改


import path from 'path'
import fs from 'fs'
this.webview.addEventListener('dom-ready', () => {
                    const filePath = myApp.isPacked ? path.resolve('static/js/webview/html.js') : 'static/js/webview/html.js'
                    const js = fs.readFileSync(filePath).toString();
                    this.webview.executeJavaScript(js);
                })

相关文章

网友评论

      本文标题:electron的webview中注入js-back

      本文链接:https://www.haomeiwen.com/subject/espqrktx.html