是否有可能使用Node.jsdynamic脚本文件注入html?
我试图从特定path获取*.js
并将脚本注入到index.html
文件中。
我用下面的node.js
代码来检索目录中的文件。
function walkSync(currentDirPath, callback) { var fs = require('fs'), path = require('path'); fs.readdirSync(currentDirPath).forEach(function (name) { var filePath = path.join(currentDirPath, name); var stat = fs.statSync(filePath); if (stat.isFile()) { callback(filePath, stat); } else if (stat.isDirectory()) { walkSync(filePath, callback); } }); } var componentsFilePath = []; walkSync("app/scripts/", function (filePath, stats) { if (filePath.indexOf(".js") > 0) { componentsFilePath.push(filePath); } }); console.log("scripts : " + componentsFilePath);
现在,我面临着注入的挑战。
不可能将上面的脚本文件注入到html
页面。
感谢您的支持。
- 在controller.js文件中处理AngularJS中的错误
- shopping-cart.hbs页面没有被渲染
- jQuery的手机redirect或更改url时,网页没有任何CSS
- 当在我的html脚本标签上使用async ='true'来加载socket.io.js时,会导致io对象的一个未定义的错误任何build议?
- 如何在HTML页面上创build一个常量脚本
- node.js和Handlebars:编译的HTML被转义
- 本地networking上的Socket.io/node.js?
- 如何在html中实现服务器端node.js
- 错误:ENOENT:没有这样的文件或目录,打开“./views/s.ejs”Nodejs Express