Accessing variables declared in node.jsejs file from javascript file

Asked 1 years ago, Updated 1 years ago, 78 views

In the ejs file of node.js,

xxx.ejs

<script>
        var temp = <%=dateinfo%>;
<script>
....
<script src="/public/test.js"></script>

Is there a way to declare a temp variable like this and access the temp variable in the test.js file?

node.js ejs

2022-09-21 10:17

1 Answers

There seems to be no reason not to. ;-)

If it doesn't work, I think I can help you more if you share the code that doesn't work.


2022-09-21 10:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.