0
点赞
收藏
分享

微信扫一扫

小朋友学Python Web(3):实现点击按纽跳转

码农K 2022-08-04 阅读 7


1 在urls.py文件的urlpatterns中添加

r'newpage', views.gotoNewPage),

2 在views.py中增加gotoNewPage函数

def gotoNewPage(request):
return render(request, 'newpage01.html')

3 在主页index.html中增加按纽及响应方法

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>测试</title>
</head>
<body>
This is my first page.


<script>function clickButton1()
// 当前窗口打开新页面
// location.href="newpage";
// 新窗口打开新页面
window.open('newpage');
}

function clickButton2()
alert("您好");
}
</script>

<br
<br
<button type="button" onclick="clickButton1()">跳转页面</button>

<br
<br
<button type="button" onclick="clickButton2()">显示弹框</button>

<br
<br
<input type = "text" name = "input01">

<br
<br
<textarea rows="3" cols = "10"></textarea>

</body>
</html>

4 在templates目录中增加newpage01.html界面,内容为

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>static</title>
</head>
<body>
这是一个新页面
</body>
</html>

小朋友学Python Web(3):实现点击按纽跳转_微信公众号


举报

相关推荐

0 条评论