Vue CLI 在没有服务器的情况下构建和运行 index.html 文件 [英] Vue CLI build and run index.html file without server

查看:25
本文介绍了Vue CLI 在没有服务器的情况下构建和运行 index.html 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是最新的 vue-cli 3.0 版.

I'm using the latest vue-cli version 3.0.

我目前的问题是,每当我运行 npm run build 时,dist 文件夹中生成的文件在没有服务器的情况下无法运行.

My current issue is that whenever I run npm run build the files generated in the dist folder can't be run without a server.

我希望能够在浏览器上打开 index.html 文件.我该怎么做?

I would like to be able to just open the index.html file on the browser. How do I go about doing this?

推荐答案

我能够通过手动更改引用文件的 url 来解决此问题.

I was able to fix this issue by manually changing the url of the referenced files.

这有点痛苦,但这是一个无需处理构建配置的解决方案.

It's a bit of a pain, but this was a solution without having to mess around with the build configuration.

您需要做什么:

  1. 打开index.html
  2. 找到href=/并替换为href=
  3. 找到 src=/ 并替换为 src=
  1. Open index.html
  2. Find href=/ and replace with href=
  3. Find src=/ and replace with src=

注意:我需要这个解决方案,因为我正在创建一个 Phonegap 应用程序.

这篇关于Vue CLI 在没有服务器的情况下构建和运行 index.html 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆