添加js文件到node.js

问题描述 投票:0回答:0

我是这个领域的新手,如果我的问题质量不高,抱歉。

我想在我的 app.js(节点主文件)中添加一个 toos.js 文件。 那是因为我想在另一个文件中使用 js 函数。不在 app.js 中 主要目标是使用按钮动态更改 iframe。 (ejs 文件)

app.js

var tools = require('./tools');

tools.js

var express = require("express");

const btnUnu = document.getElementById("gamesaunu");
const btnDoi = document.getElementById("gamesadoi");
var iframeEl = document.getElementById("iframe");


btnUnu.addEventListener("click", toggle)
btnDoi.addEventListener("click", toggleDoi)

function toggle(){
    iframeEl.src = "/Documente/S231202-2.pdf"
}
function toggleDoi(){
    iframeEl.src = "/Documente/S291040.pdf"
}

module.exports = tools

错误 日志中的错误从 const btnUnu...

开始

谢谢你,

javascript node.js module ejs node-modules
© www.soinside.com 2019 - 2024. All rights reserved.