【问题标题】:Running Web Server in File (file://) protocol在文件 (file://) 协议中运行 Web 服务器
【发布时间】:2021-08-20 05:43:57
【问题描述】:

我正在使用 Quasar 制作一个 Vue SPA 网络应用程序/页面。在这种情况下,该 Web 应用程序只能通过单击由 Quasar 打包程序创建的 index.html 文件来运行。该软件包将仅在本地分发,不会托管在域中。

现在我的问题是。由于我将使用XMLHttpRequest 打开包中的本地文件(xml 文件),因此我需要打开一个 Web 服务器。

有什么方法可以通过双击index.htmlfile:// 协议)自动启动(以编程方式)Web 服务器?

我在想这样的事情(但由于错误Cannot statically analyse 'require(…, …)' in line 74,我仍然无法让它工作):

const LocalWebServer = require('local-web-server')
const ws = LocalWebServer.create({
  port: 9000,
  directory: 'public'
})

/* shut down */
ws.server.close()

https://github.com/lwsjs/local-web-server/wiki/API-reference

谢谢!

【问题讨论】:

    标签: javascript html node.js vue.js quasar-framework


    【解决方案1】:

    不,html 文件将无法启动可执行文件并打开 tcp 端口。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-17
      • 2020-05-25
      相关资源
      最近更新 更多