azl397985856 / fe-interview

宇宙最强的前端面试指南 (https://lucifer.ren/fe-interview)
Apache License 2.0
2.84k stars 260 forks source link

【每日一题】- 2020-01-22 - 为什么打包好的dist文件夹下的index.html 不能直接打开? #99

Closed azl397985856 closed 4 years ago

azl397985856 commented 4 years ago

为什么打包好的dist文件夹下的index.html 不能直接打开?比如file:///Users/lucifer/work/code/test/dist/index.html。而需要放到服务器上才行,当然这个服务器可以是远程服务器,也可以是本地自己启动的服务器。

提示:

PS:

我的习惯是本地开发使用dev,上线之前build一下,serve(一个node cli) 命令跑一下。

into-piece commented 4 years ago

我们打包出来的是为了放在服务器上进行调用,使用的是http协议,而本地是file本地文件传输协议进行访问,中间的过程没有http服务器参与解析。

azl397985856 commented 4 years ago

@into-piece 关键点基本有了。 但是报错的原因是什么呢?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.