|
使用vite创建的项目运行时,只能使用localhost(127.0.0.1)访问,如果使用外部ip,提示使用--host参数,可使用npm run dev --host,不起作用,在host后增加0.0.0.0也不起作用。需要运行npx vite --host 0.0.0.0。还有一个办法,就是在vite.config.js中增加配置server:
export default defineConfig({
plugins: [react()],
server:{
host:"0.0.0.0"
}
})
参考:https://www.jianshu.com/p/3b0444e75ce0 |
|
|