ExpressJs + Jquery mobile制作一个登陆窗体 - andy1987

使用nodejs+jquery mobile做了个简单的登陆窗体

使用了nodejs的web开发框架expressJS,代码量少,简单,原理简单,只是写了一下午的Qt/C++闲暇放松下:)

nodejs 代码

var express = require('express'),
	app = express();

app.use( function( req, res , next ){
	console.log("method %s , Url: %s" , req.method , req.url);
	next();
});

app.use( express.bodyParser());

//login 
app.post('/login' , function(req, res){
	var username = req.body.username;
	var password = req.body.password;

	console.log("username: %s  ; password: %s" , username,password);
});

if( !module.parent)
{
	app.listen("3000" , function(){
		console.log("server is starting");
	});
}

login UI代码

<!doctype html>
<html>
<head>
	<title>My Page</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css">

	<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
	<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
	<div data-role="page" id ="first" data-theme="b">
		<div data-role="header" data-theme="a">
			<h3>login page</h3>
		</div>

		<div data-role="content">
			<form id="check-user" class="ui-body ui-body-a ui-corner-all" data-ajax="false" method="post" action="http://127.0.0.1:3000/login">
				<fieldset>
				   <div data-role="fieldcontain">
					   <label for="username">Enter your username:</label>
					   <input type="text" value="" name="username" id="username" /> 
				   </div>
				   <div data-role="fieldcontain">
					   <label for="password">Enter you password:</label>
					   <input type="password" value="" name="password" id="password" />
				   </div>
				   <input type="submit" data-theme="b" name="submit" id="submit" value="submit"/>
				</fieldset>
			</form>
			
		</div>


</body>
</html>
我来评几句
登录后评论

已发表评论数()

相关站点

热门文章