npm - real machine debugging using serve

Target

I wrote a web page that needs to be tested on the mobile side.

The PC and the mobile phone are under the same WIFI.

serve

is an npm package to quickly start a static server.

Simple to use

Prepare an index.html:

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
		  name="viewport">
	<meta content="ie=edge" http-equiv="X-UA-Compatible">
	<title>Document</title>
</head>
<body>
<h1>你好,世界!</h1>
</body>
</html>

Start the server:

npx serve

Effect:
The first is the address accessed by the machine.
The second is the address accessed within the LAN.

insert image description here

PC edge:

insert image description here
Mobile:

insert image description here

Is it possible to use any server?

To this end, I built another parcel project.
The port is 1234.

insert image description here
PC edge:

insert image description here
Mobile terminal: The IP remains unchanged, but the port number is changed.

insert image description here
It seems possible.

How to get this IP address?

Command Line:

ipconfig

Find: IPv4 address.
insert image description here

What about the Internet?

The simple way is to open a hotspot and convert it into an intranet.

What else can I do with this function?

Local area network file transfer, no internet required.

Guess you like

Origin blog.csdn.net/qq_37284843/article/details/124310057