参考源:http://blog.csdn.net/fgf00/article/details/54917439

三、Ajax操作

ajax操作基于浏览器的xmlHttpRequest对象,IE低版本是另外一个对象,jQuery 1 版本对那两个对象做了封装,兼容性最好,2 、3版本不再支持IE低版本了。

Ajax操作,用来偷偷发请求。

参考博客:

http://www.cnblogs.com/wupeiqi/articles/5703697.html

1、原生Ajax操作

XmlHttpRequest对象介绍

  • XmlHttpRequest对象的主要方法:
  1. void open(String method,String url,Boolen async)
  2. 用于创建请求
  3.  
  4. 参数:
  5. method 请求方式(字符串类型),如:POSTGETDELETE...
  6. url 要请求的地址(字符串类型)
  7. async 是否异步(布尔类型)
  8.  
  9. void send(String body)
  10. 用于发送请求
  11.  
  12. 参数:
  13. body 要发送的数据(字符串类型)
  14.  
  15. void setRequestHeader(String header,String value)
  16. 用于设置请求头
  17.  
  18. 参数:
  19. header 请求头的key(字符串类型)
  20. vlaue 请求头的value(字符串类型)
  21.  
  22. String getAllResponseHeaders()
  23. 获取所有响应头
  24.  
  25. 返回值:
  26. 响应头数据(字符串类型)
  27.  
  28. String getResponseHeader(String header)
  29. 获取响应头中指定header的值
  30.  
  31. 参数:
  32. header 响应头的key(字符串类型)
  33.  
  34. 返回值:
  35. 响应头中指定的header对应的值
  36.  
  37. void abort()
  38.  
  39. 终止请求

XmlHttpRequest对象的主要属性:

  1. a. Number readyState
  2. 状态值(整数)
  3.  
  4. 详细:
  5. 0-未初始化,尚未调用open()方法;
  6. 1-启动,调用了open()方法,未调用send()方法;
  7. 2-发送,已经调用了send()方法,未接收到响应;
  8. 3-接收,已经接收到部分响应数据;
  9. 4-完成,已经接收到全部响应数据;
  10.  
  11. b. Function onreadystatechange
  12. readyState的值改变时自动触发执行其对应的函数(回调函数)
  13.  
  14. c. String responseText
  15. 服务器返回的数据(字符串类型)
  16.  
  17. d. XmlDocument responseXML
  18. 服务器返回的数据(Xml对象)
  19.  
  20. e. Number states
  21. 状态码(整数),如:200404...
  22.  
  23. f. String statesText
  24. 状态文本(字符串),如:OKNotFound...

原生ajax示例

ajax.html

  1. <body>
  2. <input type="text" />
  3. <input type="button" value="Ajax1" onclick="Ajax1();" />
  4.  
  5. <script>
  6. function Ajax1(){
  7. var xhr = new XMLHttpRequest(); // 创建XMLHttpRequest对象
  8. xhr.open('GET','/ajax_json/',true);
  9. xhr.onreadystatechange = function(){
  10. if(xhr.readyState == 4){
  11. // 接收完毕
  12. var obj = JSON.parse(xhr.responseText);
  13. console.log(obj)
  14. }
  15. };
  16. xhr.setRequestHeader('k1','v1'); // 设置数据头
  17. xhr.send("name=root;pwd=123");
  18. }
  19. </script>
  20. </body>

urls.py

  1. url(r'^ajax_json/', views.ajax_json),
  2. url(r'^ajax/', views.ajax),

views.py

  1. def ajax(request):
  2. return render(request, "ajax.html")
  3.  
  4. def ajax_json(request):
  5. print(request.POST)
  6. ret = {'code':True, 'data':None}
  7. import json
  8. # return HttpResponse(json.dumps(ret),status=404,reason='Not Found') # 定义状态码及状态信息
  9. return HttpResponse(json.dumps(ret))

上面发送的是GET请求,如果是POST请求呢?

如上如果是POST请求,views里print(request.POST)是没有数据的,因为POST请求需要给加上请求头。

  1. <script>
  2. function Ajax1(){
  3. var xhr = new XMLHttpRequest(); // 创建XMLHttpRequest对象
  4. xhr.open('POST','/ajax_json/',true);
  5. xhr.onreadystatechange = function(){
  6. if(xhr.readyState == 4){
  7. // 接收完毕
  8. var obj = JSON.parse(xhr.responseText);
  9. console.log(obj)
  10. }
  11. };
  12. xhr.setRequestHeader('k1','v1'); // 设置数据头
  13. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset-UTF-8');
  14. xhr.send("name=root;pwd=123");
  15. }
  16. </script>

兼容性问题

以下几种写法,都是一样的效果

  1. > XMLHttpRequest
  2. XMLHttpRequest()
  3. > window.XMLHttpRequest
  4. XMLHttpRequest()
  5. > window['XMLHttpRequest']
  6. XMLHttpRequest()
  • XmlHttpRequest IE7+, Firefox, Chrome, Opera, etc.
  • ActiveXObject(“Microsoft.XMLHTTP”) IE6, IE5
  1. <script type="text/javascript">
  2.  
  3. function getXHR(){ // 兼容性判断
  4. var xhr = null;
  5. if(XMLHttpRequest){
  6. xhr = new XMLHttpRequest();
  7. }else{
  8. xhr = new ActiveXObject("Microsoft.XMLHTTP");
  9. }
  10. return xhr;
  11. }
  12.  
  13. function XhrPostRequest(){
  14. var xhr = getXHR();
  15. // 定义回调函数
  16. xhr.onreadystatechange = function(){
  17. if(xhr.readyState == 4){
  18. // 已经接收到全部响应数据,执行以下操作
  19. var data = xhr.responseText;
  20. console.log(data);
  21. }
  22. };
  23. // 指定连接方式和地址----文件方式
  24. xhr.open('POST', "/test/", true);
  25. // 设置请求头
  26. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset-UTF-8');
  27. // 发送请求
  28. xhr.send('n1=1;n2=2;');
  29. }
  30.  
  31. function XhrGetRequest(){
  32. var xhr = GetXHR();
  33. // 定义回调函数
  34. xhr.onreadystatechange = function(){
  35. if(xhr.readyState == 4){
  36. // 已经接收到全部响应数据,执行以下操作
  37. var data = xhr.responseText;
  38. console.log(data);
  39. }
  40. };
  41. // 指定连接方式和地址----文件方式
  42. xhr.open('get', "/test/", true);
  43. // 发送请求
  44. xhr.send();
  45. }
  46.  
  47. </script>

jQuery的ajax

如果在jQuery的ajax的回调函数里,再写上一些参数,里面的参数接收的就是xmlHttpRequest对象,功能和上面是一模一样的。

2、伪ajax(iframe标签)

iframe标签,会把网址嵌套在网页中,iframe里的网址更改,网页是不刷新的。

  1. <iframe src="http://blog.csdn.net/fgf00"></iframe>

示例:输入http://……网址,跳转

  1. <body>
  2. <input type="text" id="url" />
  3. <input type="button" value="Iframe请求" onclick="iframeRequest();" />
  4. <iframe src="http://blog.csdn.net/fgf00" id="ifm"></iframe>
  5.  
  6. <script src="/static/jquery-1.12.4.js"></script>
  7. <script>
  8. function iframeRequest(){
  9. var url = $('#url').val();
  10. console.log(url);
  11. $('#ifm').attr('src',url);
  12. }
  13. </script>
  14. </body>

示例:iframe伪ajax提交

可以把form提交转交给iframe,iframe提交,利用这个特性,实现伪ajax操作。

ajax.html

  1. <form action="/ajax_json/" method="POST" target="ifm1">
  2. {% csrf_token %}
  3. <iframe id="ifm1" name="ifm1"></iframe>
  4. <input type="text" name="username" placeholder="用户名"/>
  5. <input type="text" name="email" placeholder="邮箱地址"/>
  6. <input type="submit" value="Form提交">
  7. </form>

views.py

  1. def ajax_json(request):
  2. print(request.POST)
  3. ret = {'code':True, 'data':request.POST.get('username')}
  4. import json
  5. return HttpResponse(json.dumps(ret))

阻止iframe里引用的网页自动跳转

在一些新版本的浏览器里,iframe标签居然自动跳转,禁用如下:

在iframe标签中增加两个属性:

  1. security="restricted" sandbox=""

前者是IE的禁止js的功能,后者是HTML5的功能。刚好就可以让IE,Chrome,Firefox这三大浏览器都实现了禁止iframe的自动跳转。

iframe获取返回的数据

浏览器审查元素中,iframe加载的时候在document对象里,相当于一个上下文或者空间管理,在HTML里面又嵌套了一个HTML。不能通过以前的方法获取到。

iframe接收到服务端返回的数据后,会执行onload事件,获取返回数据如下:

  1. <form action="/ajax_json/" method="POST" target="ifm1">
  2. {% csrf_token %}
  3. <iframe id="ifm1" name="ifm1" onload="iframeLoad();"></iframe>
  4. <input type="text" name="username" placeholder="用户名"/>
  5. <input type="text" name="email" placeholder="邮箱地址"/>
  6. <input type="submit" value="Form提交" onclick="submitForm();"/>
  7. </form>
  8.  
  9. <script src="/static/jquery-1.12.4.js"></script>
  10. <script>
  11. function submitForm(){ // 当点击提交的时候,才给iframe绑定load事件
  12. // 比在html中这样添加好一点:<iframe name="ifm1" onload="iframeLoad();"></iframe>
  13. $('#ifm1').load(function(){
  14. var text = $('#ifm1').contents().find('body').text(); // document对象下面的值
  15. var obj = JSON.parse(text);
  16. console.log(obj);
  17. })
  18. }
  19.  
  20. function iiframeLoad(){
  21. console.log(123)
  22. }
  23. </script>

ajax操作,使用方式选择

  1. 如果发送的是【普通数据】 : jQuery > XMLHttpRequest > iframe

3、ajax 文件上传(三种方式)及 图片预览

urls.py

  1. url(r'^upload/$', views.upload),
  2. url(r'^upload_file/', views.upload_file),

views.py

  1. def upload(request):
  2. return render(request,'upload.html')
  3.  
  4. def upload_file(request):
  5. username = request.POST.get('username')
  6. fafafa = request.FILES.get('fafafa')
  7. import os
  8. img_path = os.path.join('static/imgs/',fafafa.name)
  9. with open(img_path,'wb') as f:
  10. for item in fafafa.chunks():
  11. f.write(item)
  12.  
  13. ret = {'code': True , 'data': img_path} # 返回文件路径(图片预览用)
  14. import json
  15. return HttpResponse(json.dumps(ret))

upload.html

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title></title>
  6. <style>
  7. .upload{
  8. display: inline-block;padding: 10px;
  9. background-color: #2459A2;
  10. color: white;
  11. position: absolute;
  12. top: 0;
  13. bottom: 0;
  14. right: 0;
  15. left: 0;
  16. z-index: 90;
  17. }
  18. .file{
  19. width: 60px;height: 30px;opacity: 0;
  20. position: absolute;
  21. top: 0;
  22. bottom: 0;
  23. right: 0;
  24. left: 0;
  25. z-index: 100;
  26. }
  27. </style>
  28. </head>
  29. <body>
  30. <div style="position: relative;width: 60px;height: 30px;">
  31. <input class="file" type="file" id="fafafa" name="afafaf" />
  32. <a class="upload">上传</a>
  33. </div>
  34. <input type="button" value="提交XHR" onclick="xhrSubmit();" />
  35. <input type="button" value="提交jQuery" onclick="jqSubmit();" />
  36. <hr/>
  37.  
  38. <form id="form1" action="/upload_file/" method="POST" enctype="multipart/form-data" target="ifm1">
  39. <iframe id="ifm1" name="ifm1" style="display: none;"></iframe>
  40. <input type="file" name="fafafa"/>
  41. <input type="submit" onclick="iframeSubmit();" value="iframe提交"/> <!--iframe方式提交-->
  42. <hr>选中后,就上传、图片预览 <!--iframe方式提交,选中后,就上传,并图片预览-->
  43. <input type="file" name="fafafa" onchange="changeUpalod();" /> <!--iframe方式提交,选择后,就图片预览-->
  44. </form>
  45.  
  46. <div id="preview"></div> <!-- 图片预览使用 -->
  47.  
  48. <script src="/static/jquery-1.12.4.js"></script>
  49. <script>
  50. // 选中后,就上传文件,并图片预览
  51. function changeUpalod(){
  52. $('#ifm1').load(function(){
  53. var text = $('#ifm1').contents().find('body').text();
  54. var obj = JSON.parse(text);
  55.  
  56. $('#preview').empty();
  57. var imgTag = document.createElement('img');
  58. imgTag.src = "/" + obj.data;
  59. $('#preview').append(imgTag);
  60. });
  61. $('#form1').submit();
  62. }
  63. // 第二种方式:基于jQuery方式上传文件
  64. function jqSubmit(){
  65. // $('#fafafa')[0]
  66. var file_obj = document.getElementById('fafafa').files[0]; // files代表上传的文件
  67.  
  68. var fd = new FormData(); // 相当于表单
  69. fd.append('username','root');
  70. fd.append('fafafa',file_obj);
  71.  
  72. $.ajax({
  73. url: '/upload_file/',
  74. type: 'POST',
  75. data: fd,
  76. // 上传文件时,添加以下两个参数是告诉jQuery,不要做特殊处理
  77. processData: false, // tell jQuery not to process the data
  78. contentType: false, // tell jQuery not to set contentType
  79. success:function(arg,a1,a2){
  80. console.log(arg);
  81. console.log(a1);
  82. console.log(a2); // 多写几个参数,这个参数包含xmlHttpRequest对象
  83. }
  84. })
  85. }
  86. // 第一种方式:基于xmlHttpRequest方式上传文件
  87. function xhrSubmit(){
  88. // $('#fafafa')[0]
  89. var file_obj = document.getElementById('fafafa').files[0];
  90.  
  91. var fd = new FormData();
  92. fd.append('username','root');
  93. fd.append('fafafa',file_obj);
  94.  
  95. var xhr = new XMLHttpRequest();
  96. xhr.open('POST', '/upload_file/',true);
  97. xhr.onreadystatechange = function(){
  98. if(xhr.readyState == 4){
  99. // 接收完毕
  100. var obj = JSON.parse(xhr.responseText);
  101. console.log(obj);
  102. }
  103. };
  104. xhr.send(fd);
  105. }
  106. // 第三种方式:基于iframe方式上传文件
  107. function iframeSubmit(){
  108. $('#ifm1').load(function(){
  109. var text = $('#ifm1').contents().find('body').text();
  110. var obj = JSON.parse(text);
  111.  
  112. // 图片预览
  113. $('#preview').empty(); // 清空之前的预览图片
  114. var imgTag = document.createElement('img');
  115. imgTag.src = "/" + obj.data; // 绑定预览图片路径
  116. $('#preview').append(imgTag);
  117. })
  118. }
  119.  
  120. </script>
  121. </body>
  122. </html>

xmlHttpRequest和jQuery上传文件,都是基于FormData,但是FormData对于IE一些低版本浏览器是不支持的。

一般情况下,上传图片、头像都是用iframe来实现的。

ajax操作,使用方式选择

  1. 如果发送的是【文件】 : iframe > jQuery(FormData) > XMLHttpRequest(FormData)

四、图片验证码

流程:

  • 访问页面`/login/

    • 创建一个图片并给用户返回
    • Session存放验证码
  • 用户POST提交数据,对比

实现:

页面生成返回和生成图片:生成网页html、生成图片url分开,这样更新验证码图片是,网页是不用刷新的。

views

  1. from io import BytesIO
  2. from django.shortcuts import HttpResponse
  3. from utils.check_code import create_validate_code
  4.  
  5. def check_code(request):
  6. """
  7. 验证码
  8. :param request:
  9. :return:
  10. """
  11. # 直接打开图片,返回
  12. # data = open('static/imgs/avatar/20130809170025.png','rb').read()
  13. # return HttpResponse(data)
  14.  
  15. # 通过模块生成图片并返回
  16. # 1. 创建一张图片 pip3 install Pillow
  17. # 2. 在图片中写入随机字符串
  18. # obj = object()
  19. # 3. 将图片写入到指定文件
  20. # 4. 打开指定目录文件,读取内容
  21. # 5. HttpResponse(data)
  22. stream = BytesIO() # 在内存里开辟一块空间,在内存里直接读写,相当于打开一个文件
  23. img, code = create_validate_code()
  24. img.save(stream,'PNG') # 把生成的图片进行保存
  25. request.session['CheckCode'] = code # 把验证码放入session中
  26. return HttpResponse(stream.getvalue()) # 在内存中读取并返回

create_validate_code

  1. font_type="Monaco.ttf", # 依赖的字体

html

  1. <img src="/check_code.html" onclick="changeCheckCode(this);">
  2. <script>
  3. function changeCheckCode(ths){
  4. ths.src = ths.src + '?'; // URL不变:浏览器不发请求;加上?号,get参数请求,向后台发请求
  5. }
  6. </script>

check_code.py(依赖:Pillow,字体文件)

  1. pip3 install Pillow

五、KindEditor富文本编辑器

常用的富文本编辑器:CKEditor,UEEditor,TinyEditor,KindEditor

进入KindEditor官网

文件夹说明

  1. ├── asp asp示例
  2. ├── asp.net asp.net示例
  3. ├── attached 空文件夹,放置关联文件attached
  4. ├── examples HTML示例
  5. ├── jsp java示例
  6. ├── kindeditor-all-min.js 全部JS(压缩)
  7. ├── kindeditor-all.js 全部JS(未压缩)
  8. ├── kindeditor-min.js KindEditor JS(压缩)
  9. ├── kindeditor.js KindEditor JS(未压缩)
  10. ├── lang 支持语言
  11. ├── license.txt License
  12. ├── php PHP示例
  13. ├── plugins KindEditor内部使用的插件
  14. └── themes KindEditor主题

基本使用

  1. <textarea name="content" id="content"></textarea>
  2.  
  3. <script src="/static/jquery-1.12.4.js"></script>
  4. <script src="/static/plugins/kind-editor/kindeditor-all.js"></script>
  5. <script>
  6. $(function () {
  7. initKindEditor();
  8. });
  9.  
  10. function initKindEditor() {
  11. var kind = KindEditor.create('#content', {
  12. width: '100%', // 文本框宽度(可以百分比或像素)
  13. height: '300px', // 文本框高度(只能像素)
  14. minWidth: 200, // 最小宽度(数字)
  15. minHeight: 400 // 最小高度(数字)
  16. });
  17. }
  18. </script>

详细参数

  1. http://kindeditor.net/docs/option.html

常用参数

  1. items # 配置显示多少个工具
  2. noDisableItems # designMode 为false时,要保留的工具,置灰
  3. filterMode # true时根据 htmlTags 过滤HTML代码,false时允许输入任何代码。
  4. resizeType # 2或1或0,2时可以拖动改变宽度和高度,1时只能改变高度,0时不能拖动。
  5. syncType # 设置”“、”form”,值为form时提交form时自动提交,空时不会自动提交。
  6. uploadJson # 指定上传文件的服务器端程序。
  7. autoHeightMode # 内容多时,自动调整高度。

uploadjson

  1. <textarea id="content"></textarea>
  2.  
  3. <script src="/static/jquery-1.12.4.js"></script>
  4. <script src="/static/kindeditor-4.1.10/kindeditor-all.js"></script>
  5. <script>
  6. KindEditor.create('#content', {
  7. uploadJson: '/upload_img/',
  8. fileManagerJson: '/file_manager/', // 文件管理路径
  9. allowImageRemote: true, // 是否允许远程上传
  10. allowImageUpload: true, // 是否允许本地上传
  11. allowFileManager: true, // 图片空间,文件预览功能
  12. extraFileUploadParams: { // CSRF限制,提交csrf
  13. csrfmiddlewaretoken: "{{ csrf_token }}"
  14. },
  15. filePostName: 'fafafa' // 设置文件发送的name值,方便后台获取
  16. });
  17. })
  18. </script>
  1. def upload_img(request):
  2. request.GET.get('dir')
  3. print(request.FILES.get('fafafa'))
  4. # 获取文件保存
  5. import json
  6. dic = {
  7. 'error': 0,
  8. 'url': '/static/imgs/20130809170025.png',
  9. 'message': '错误了...'
  10. }
  11. return HttpResponse(json.dumps(dic))
  12.  
  13. import os, time, json
  14. def file_manager(request):
  15. """
  16. 文件管理,照片空间
  17. :param request:
  18. :return:
  19. """
  20. dic = {}
  21. root_path = 'C:/Users/Administrator/PycharmProjects/day24/static/'
  22. static_root_path = '/static/'
  23. request_path = request.GET.get('path')
  24. if request_path:
  25. abs_current_dir_path = os.path.join(root_path, request_path)
  26. move_up_dir_path = os.path.dirname(request_path.rstrip('/'))
  27. dic['moveup_dir_path'] = move_up_dir_path + '/' if move_up_dir_path else move_up_dir_path
  28.  
  29. else:
  30. abs_current_dir_path = root_path
  31. dic['moveup_dir_path'] = ''
  32.  
  33. dic['current_dir_path'] = request_path
  34. dic['current_url'] = os.path.join(static_root_path, request_path)
  35.  
  36. file_list = []
  37. for item in os.listdir(abs_current_dir_path):
  38. abs_item_path = os.path.join(abs_current_dir_path, item)
  39. a, exts = os.path.splitext(item)
  40. is_dir = os.path.isdir(abs_item_path)
  41. if is_dir:
  42. temp = {
  43. 'is_dir': True,
  44. 'has_file': True,
  45. 'filesize': 0,
  46. 'dir_path': '',
  47. 'is_photo': False,
  48. 'filetype': '',
  49. 'filename': item,
  50. 'datetime': time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(os.path.getctime(abs_item_path)))
  51. }
  52. else:
  53. temp = {
  54. 'is_dir': False,
  55. 'has_file': False,
  56. 'filesize': os.stat(abs_item_path).st_size,
  57. 'dir_path': '',
  58. 'is_photo': True if exts.lower() in ['.jpg', '.png', '.jpeg'] else False,
  59. 'filetype': exts.lower().strip('.'),
  60. 'filename': item,
  61. 'datetime': time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(os.path.getctime(abs_item_path)))
  62. }
  63.  
  64. file_list.append(temp)
  65. dic['file_list'] = file_list
  66. return HttpResponse(json.dumps(dic))

Day24-Ajax操作、图片验证码、KindEditor使用-转的更多相关文章

  1. Django(九)下:Ajax操作、图片验证码、KindEditor使用

    三.Ajax操作 ajax操作基于浏览器的xmlHttpRequest对象,IE低版本是另外一个对象,jQuery 1 版本对那两个对象做了封装,兼容性最好,2 .3版本不再支持IE低版本了. Aja ...

  2. day20 project+查看新闻列表 + 点赞 + 图片验证码 + 评论和多级评论 + 后台管理 + webSocket + kindEditor

    Day20回顾: 1. 请求生命周期 2. 中间件 md = [ "file_path.classname" ] process_request[可有可无] process_res ...

  3. Django项目开发,XSS攻击,图片防盗链,图片验证码,kindeditor编辑器

    目录 一.Django项目开发 1. 项目开发流程 2. auth模块的补充 (1)django的admin可视化管理页面 (2)将admin可视化管理页面的模型表显示成中文 (3)auth模块的用户 ...

  4. Python开发【Django】:图片验证码、KindEditor

    图片验证码 生成图片验证码需要以下: session check_code.py(依赖:Pillow,字体文件) 模块安装 pip install Pillow src属性后面加? 在utils下拷贝 ...

  5. 【Spring】基于SpringMVC的图片验证码功能实现

    后台实现代码: ImgController.java 文件 package cn.shop.controller; import java.awt.Color; import java.awt.Fon ...

  6. 图片验证码——base64编码的使用

    一.介绍: 1.base64编码简介: Base64就是一种编码格式.Base64要求把每三个8Bit的字节转换为四个6Bit的字节(3*8 = 4*6 = 24),然后把6Bit再添两位高位0,组成 ...

  7. django(7)modelform操作及验证、ajax操作普通表单数据提交、文件上传、富文本框基本使用

    一.modelForm操作及验证 1.获取数据库数据,界面展示数据并且获取前端提交的数据,并动态显示select框中的数据 views.py from django.shortcuts import ...

  8. Django 六——自定义标签、图片验证码、发送邮件、评论树、组合搜索

    1.自定义标签 2.图片验证码 3.生成邮箱验证码.发送邮件 4.评论树实现 5.组合搜索(Q) 1.自定义标签 配置: a.在app中新建文件夹  templatetags,里面新建  xx.py文 ...

  9. vue 弹窗式 滑动图片验证码

    效果图: 具体代码: test.vue //整个页面是个弹窗 visible 控制弹窗的显示关闭 默认打开 <template> <div class="mask_laye ...

随机推荐

  1. R 语言-基础

    R语言 1997年成为GNU项目 开源免费 R官方网址 www.r-project.org R是数据分析领域的语言小巧灵活,通过扩展包来增强功能绘图功能代码简单 开发环境R + RStudio 1.数 ...

  2. Python3入门(三)——Python基础语法

    一.基本语法 1.行和缩进 Python中,不使用括号来表示代码的类和函数定义块或流程控制. 代码块是由行缩进,缩进位的数目是可变的,但是在块中的所有语句必须缩进相同的量. 如下所示: a = 100 ...

  3. controlfile作为RMAN的repository时,对 keep time 的测试

    4月2日,首先查看系统状况: SQL> show parameter control NAME                                 TYPE        VALUE ...

  4. mfc 虚函数

    知识点 类虚函数概念 类虚函数定义virtual 一.虚函数 简单地说,那些被virtual关键字修饰的成员函数,就是虚函数. 二.虚函数定义 定义:在某基类中声明为 virtual 并在一个或多个派 ...

  5. GIT命令基本使用

    记录摘选自廖雪峰的官方网站归纳总结 1.centos下安装git [root@cdw-lj ~]# yum install git 2.配置用户名以及邮箱 [root@cdw-lj opt]# git ...

  6. Shell基础入门

    目录 Shell基础入门 1.什么是Shell? 2.Shell脚本的结构 3.Shell的变量 3.1.自定义环境变量 3.2.普通变量 3.3.位置参数变量 3.4.状态变量 4.条件测试和比较 ...

  7. P2371 [国家集训队]墨墨的等式

    膜意义下最短路. 把最小的\(a\)抠出来,作为模数\(mod\),然后建点编号为\(0\)到\(mod-1\),对每个数\(a\)连边\((i,(a+i)\mod mod)\)点\(i\)的最短路就 ...

  8. 项目 - RM 部署上centos7 之后出现的一些问题和解决方法

    系统版本: [root@localhost logs]# cat /etc/redhat-release CentOS Linux release (Core) 获取方法来自:https://www. ...

  9. REST-framework快速构建API--权限

    我们在访问资源时,有些资源保密程度较高,需要特殊的人员才能访问.比如,获取公司的每日收入流水的API接口,只能CEO才能查看. 这时,我们就需要将资源设定权限了. REST-framework实现如下 ...

  10. docker之搭建私有仓库

    一.私有仓库 1.防止网络原因:下载慢,访问不到的情况,需要在内网搭建一个私有仓库. 二.仓库镜像下载 [root@node03 ~]# docker pull registry 三.创建私有仓库容器 ...