当前位置:网站首页>Vite打包后的dist不能直接在浏览器打开吗
Vite打包后的dist不能直接在浏览器打开吗
2022-07-02 05:41:00 【用户体验官大龙】
不能
原因
Vite 本身依赖于原生ES模块来做模块加载,而原生ES模块是不支持 file://
本地访问的。
解决办法
方案一:使用http-server插件启动
1.安装node.js;(已安装跳过)
2.安装http-server。
npm install http-server -g
或
yarn global add http-server
3、进入dist根目录执行启动项目
http-server
方案二:使用nginx启动
1、把dist拷贝至nginx的html目录下(其他目录也行,需在nginx里配置root);
2、配置nginx.conf
3、保存并启动nginx,访问http://127.0.0.1:3000即可。
(完)
边栏推荐
- With an amount of $50billion, amd completed the acquisition of Xilinx
- 《CGNF: CONDITIONAL GRAPH NEURAL FIELDS》阅读笔记
- Lingyunguang rushes to the scientific innovation board: the annual accounts receivable reaches 800million. Dachen and Xiaomi are shareholders
- 文件包含漏洞(一)
- Zzuli:1064 encrypted characters
- Technologists talk about open source: This is not just using love to generate electricity
- 测试 - 用例篇
- Fabric. JS basic brush
- 3D printer G code command: complete list and tutorial
- Zzuli:1061 sequential output of digits
猜你喜欢
Visual studio import
Gee series: Unit 2 explore datasets
[personal test] copy and paste code between VirtualBox virtual machine and local
7.TCP的十一种状态集
数据的储存
Conglin environmental protection rushes to the scientific and Technological Innovation Board: it plans to raise 2billion yuan, with an annual profit of more than 200million yuan
Cambrian was reduced by Paleozoic venture capital and Zhike shengxun: a total of more than 700million cash
文件包含漏洞(二)
2022-2-14 learning xiangniuke project - Section 7 account setting
Minimum value ruler method for the length of continuous subsequences whose sum is not less than s
随机推荐
Straighten elements (with transition animation)
软件测试基础篇
Principle and implementation of parallax effect
Simply encapsulate JS and apply it
Huawei Hongmeng OS, is it OK?
H5 jump applet
Uva548 tree
How to change the IP address of computer mobile phone simulator
文件包含漏洞(二)
青训营--数据库实操项目
I want to understand the swift code before I learn it. I understand it
5g market trend in 2020
2022-2-14 learning xiangniuke project - section 23, section 5, development login and exit functions
Ls1046nfs mount file system
“简单”的无限魔方
Installation du tutoriel MySQL 8.0.22 par centos8
1037 Magic Coupon
ThreadLocal memory leak
Gee: use of common mask functions in remote sensing image processing [updatemask]
Importation de studio visuel