从HTML运行时require()失败,但在直接运行javascript时可以运行

时间:2018-06-23 02:53:59

标签: javascript html node.js

基本上,每当我尝试从javascript运行代码时,都可以在我认为是node的地方找到http.js。但是,当通过HTML在网页上运行时会报告错误:

  

获取http://localhost:63342/weather/https.js

我认为是错误的,因为两者之间的运行时位置不同,并且它们只是从两个不同的位置提取。这是在网络风暴中完成的。

代码只不过是HTML中的<script src=...>和JavaScript中的require("https")。通过HTML运行时,将require部分更改为

require(['https'], function (https) {
    https=require("https")
});

我相信是出于异步原因。

0 个答案:

没有答案
相关问题