打字稿 – 电子,Angular2,“fs”
发布时间:2020-12-17 07:49:37 所属栏目:安全 来源:网络整理
导读:我对Angular,Javascript等主题很新. 我尝试编写一个应该访问文件系统的(TypeScript)Angular2-Electron应用程序.每个人只是说要求“fs”模块,一切都很好,但这对我不起作用…. 如果我这样做:var fs = require(‘fs’); 我可以看到我的应用尝试从我的应用根文
我对Angular,Javascript等主题很新.
我尝试编写一个应该访问文件系统的(TypeScript)Angular2-Electron应用程序.每个人只是说要求“fs”模块,一切都很好,但这对我不起作用…. 如果我这样做:var fs = require(‘fs’); 我可以看到我的应用尝试从我的应用根文件夹加载“fs”模块: 我在index.html中引用了所有其他外部模块: <!-- build:js app/scripts/combined.js --> <script src="../node_modules/jquery/dist/jquery.js"></script> <script src="../node_modules/angular2/bundles/angular2-polyfills.js"></script> <script src="../node_modules/systemjs/dist/system.js"></script> <script src="../node_modules/angular2/bundles/angular2.dev.js"></script> <script src="../node_modules/angular2/bundles/http.js"></script> <script src="../node_modules/angular2/bundles/router.js"></script> <script src="../node_modules/rxjs/bundles/Rx.js"></script> <script src="../node_modules/bootstrap/dist/js/bootstrap.js"></script> <script src="../node_modules/pdfjs-dist/build/pdf.combined.js"></script> <script src="boot.js" type="text/javascript"></script> <!-- endbuild --> 因此我认为它们可以找到,但“fs”属于存在于电子中的node.js?或者我在思想上犯了一些重大错误? 非常感谢,
问题似乎是我在Angular应用程序中使用SystemJS. SystemJS尝试从我自己的应用程序加载模块.
我现在添加这个,所以我的index.html似乎工作: <script> if (require) { window.$= window.jQuery = require('./app/assets/js/jquery.min.js'); window.fs = require('fs'); window.path = require('path'); } </script> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |