After the vue project is running, use the ip address to open it on the phone


1. Obtain the ip address

window+r, enter cmd and press Enter, then enter ipconfig
insert image description here

The ipv4 address is yours

2. Make sure your mobile phone and computer use the same wifi

3. Modify the configuration file

(1) Modify the vue.config.js file host localhostto host 0.0.0.0
(2) Your vue.config.js file can be configured in the index.js file of the config folder due to more configurations. (
insert image description here
3) Modify the package.json file to add –host 0.0.0.0, and then restart the project.
"scripts": { "dev": "webpack-dev-server --host 0.0.0.0 --inline --progress --config build/webpack.dev.conf.js", }

Note: After re-running the project, use the ip address plus the port number, such
as: http://192.168.101.101:8080

Guess you like

Origin blog.csdn.net/weixin_44784401/article/details/131463862