在 vite.config.js
中添加 server对象,host
为 0.0.0.0,port为8000
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
server:{
host:'0.0.0.0',
port:'8000'
}
})
添加后运行 npm run dev
VITE v3.1.0 ready in 595 ms
➜ Local: http://localhost:8000/
➜ Network: http://192.168.0.103:8000/