no message

This commit is contained in:
chenxuan
2024-01-16 16:20:20 +08:00
parent 69f084d233
commit d4daaf82ee
4 changed files with 13 additions and 22 deletions
-3
View File
@@ -1,3 +0,0 @@
document.getElementById('img').onclick=function(){
alert("呵呵呵!")
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

+10 -3
View File
@@ -6,19 +6,26 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>处理静态资源</title>
<style>
li{
list-style: none;
}
.img{
width: 1200px;
/* height: 500px; */
}
.img img{
width: 100%;
width: 300px;
/* height: 100%; */
}
</style>
</head>
<body>
<h1>处理静态资源</h1>
<li class="img"><img src="img.jpg" alt="" id="img"></li>
<script src="click.js"></script>
<li class="img"><img src="img.jpeg" alt="" id="img"></li>
<script>
document.getElementById('img').onclick=function(){
alert("呵呵呵!")
}
</script>
</body>
</html>
+3 -16
View File
@@ -2,7 +2,7 @@ var http =require('http');
var fs=require('fs');
var server=http.createServer();
server.on('request',function(req,res){
// res.end('hello!');
var urls=req.url;
if(urls=='/'){
fs.readFile('./index.html',function(err,data){
@@ -10,24 +10,11 @@ server.on('request',function(req,res){
console.log(err)
}
else{
res.writeHead(200, { 'content-type': 'text/html;charset=utf-8' });
res.writeHead(200, { 'content-type': 'text/html;charset=utf-8'});
res.end(data);
}
})
}
//挨个写入路由
// else if(urls=='/img.jpg'){
// fs.readFile('./img.jpg',function(err,data){
// if(err){
// console.log(err)
// }
// else{
// res.writeHead(200, { 'content-type': 'text/html;charset=utf-8' });
// res.end(data);
// }
// })
// }
//通用方法
else{
fs.readFile('.'+req.url,function(err,data){
if(err){
@@ -41,5 +28,5 @@ server.on('request',function(req,res){
}
})
server.listen(8082,function(){
console.log('8080端口启动成功!')
console.log('8082端口启动成功!')
})