10 2022 档案
摘要:不具名插槽 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" conte
阅读全文
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="wi
阅读全文
摘要:概念 各个组件间,数据,方法,都是隔离的 通过自定义属性,实现父传子 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"
阅读全文
摘要:概念 # 作用:扩展 HTML 元素,封装可重用的代码,目的是复用 -例如:有一个轮播,可以在很多页面中使用,一个轮播有js,css,html -组件把js,css,html放到一起,有逻辑,有样式,有html # 多组件页面和单组件页面 -官方推荐,以后一个组件是一个 xx.vue 文件 》编译
阅读全文
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="wi
阅读全文
摘要:概念 计算 属性: 1 以后当属性用 2 只有关联的数据变化,才重新运算 3 有缓存,数据没有变化,页面再更新,它也不变化 例子 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <
阅读全文
摘要:跨域问题 -浏览器有个安全策略:不允许向不同域(地址+端口号)发送请求获取数据,浏览器的 同源策略 -解决跨域: -后端的Cors(跨域资源共享)技术:就是在响应头中加入允许即可Https://Www.Cnblogs.Com/Sherwin1995/Articles/16832830.Html -N
阅读全文
摘要:方法1 安装django-cors-headers pip install django-cors-headers settings INSTALLED_APPS = [ 'corsheaders', ] MIDDLEWARE = [ 'corsheaders.middleware.CorsMidd
阅读全文
摘要:它们有生命周期:从创建开始,到销毁 vue中总共生命周期有8个钩子函数(4对),依次调用 钩子的意思:aop的体现 beforeCreate 创建Vue实例,组件实例对象创建 之前调用 created 创建Vue实例成功后调用(咱们用的对,可以在此处发送ajax请求后端数据) beforeMount
阅读全文
摘要:lazy:双向数据绑定,只要修改输入框的值,就再更新数据,耗费资源,加了lazy后,等不输入了,变量再变化 number:输入框,只接收数字部分,如果输入了 123asdfasd,只保留123 数字部分 trim: 去掉输入内容前后的空 <!DOCTYPE html> <html lang="en"
阅读全文
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="vue.js"></script> </head> <body> <div id="app"> <tabl
阅读全文
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="vue.js"></script> </head> <body> <div id="app"> <h1>表
阅读全文
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="vue.js"></script> </head> <body> <div id="app"> <!--
阅读全文
摘要:# 放在事件后的 @click.once='函数' .stop 只处理自己的事件,不再冒泡给父标签(阻止事件冒泡) .self 只处理自己的事件,子控件冒泡的事件不处理 .prevent 阻止a链接的跳转 .once 事件只会触发一次(适用于抽奖页面) <!DOCTYPE html> <html l
阅读全文
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="vue.js"></script> </head> <body> <div id="app"> <inpu
阅读全文
摘要:# 事件:click dbclick blur input change 单击 双击 失去焦点 输入内容 发生变化 # input框会有blur, input, change 事件 使用 <!DOCTYPE html> <html lang="en"> <head> <meta charset="U
阅读全文
摘要:# input :text,password,select... # text文本类型的双向数据绑定 -使用 :value='变量' 单向数据绑定,页面变化,变量不会跟着变 》一般不用 -使用 v-model='变量' 双向数据绑定,页面变化,变量变化都会相互影响 使用 <!DOCTYPE html
阅读全文
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="vue.js"></script> </head> <body> <div id="app"> <h2>v
阅读全文
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="vue.js"></script> </head> <body> <div id="app"> <h2>#
阅读全文
摘要:<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0,
阅读全文
摘要:代码 <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1
阅读全文
摘要:代码 <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1
阅读全文
摘要:代码 <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1
阅读全文
摘要:安装第三方包 pip install django-filter 过滤1 view from django_filters.rest_framework import DjangoFilterBackend class BlogView(ModelViewSet): queryset = model
阅读全文
摘要:自动生成路由对应关系 路由 from rest_framework import routers router = routers.SimpleRouter() router.register(r'blog', blogViews.BlogView) router.register(r'regist
阅读全文
摘要:根据是否有pk 切换序列化器 get_serializer_class源码 def get_serializer_class(self): """ Return the class to use for the serializer. Defaults to using `self.serializ
阅读全文
摘要:ListModelMixin 源码 class ListModelMixin: """ List a queryset. """ def list(self, request, *args, **kwargs): queryset = self.filter_queryset(self.get_qu
阅读全文
摘要:关系 from rest_framework.generics import GenericAPIView from rest_framework.viewsets import ViewSetMixin, GenericViewSet ViewSetMixin+GenericAPIView = G
阅读全文
摘要:list APIView class DemoView(APIView): def get(self, request): queryset = models.UserInfo.objects.all() pager = PageNumberPagination() result = pager.p
阅读全文
摘要:settings REST_FRAMEWORK = { # 分页,limit大小 "PAGE_SIZE": 2, } views class BlogView(APIView): def get(self, request, *args, **kwargs): queryset = models.B
阅读全文
摘要:分页类 # 自定义分页类 class MyPageNumberPagination(PageNumberPagination): # 默认每页大小 page_size = 1 # 最大每页大小 max_page_size = 3 # 控制每页大小的查询字段 page_size_query_param
阅读全文
摘要:settings REST_FRAMEWORK = { # 分页,每页大小 "PAGE_SIZE": 2, } views class BlogView(APIView): """ get: 返回所有blog """ def get(self, request, *args, **kwargs):
阅读全文
摘要:安装 pip install coreapi 设置接口文档路径 from rest_framework.documentation import include_docs_urls urlpatterns = [ ... path('docs/', include_docs_urls(title='
阅读全文
摘要:目的 (gender = models.SmallIntegerField(verbose_name='性别', choices=((1, "男"), (2, "女")))) 输入 { "name": "szw", "gender": 2 } 返回 { "id": 2, "age": 18, "ge
阅读全文
摘要:models class Depart(models.Model): name = models.CharField(verbose_name='部门名', max_length=32) class Tag(models.Model): name = models.CharField(verbose
阅读全文
摘要:models class Depart(models.Model): name = models.CharField(verbose_name='部门名', max_length=32) class Tag(models.Model): name = models.CharField(verbose
阅读全文
摘要:model class Depart(models.Model): name = models.CharField(verbose_name='部门名', max_length=32) level = models.IntegerField(verbose_name='等级',default=1)
阅读全文
摘要:序列化器Serializer class DepartSerializer(serializers.Serializer): name = serializers.CharField(required=True, max_length=3, min_length=2) age = serialize
阅读全文
摘要:models class Depart(models.Model): name = models.CharField(verbose_name='部门名', max_length=32) 序列化器 class DepartSerializer(serializers.ModelSerializer)
阅读全文
摘要:models class Depart(models.Model): name = models.CharField(verbose_name='部门名', max_length=32) class Tag(models.Model): name = models.CharField(verbose
阅读全文
摘要:models class Depart(models.Model): name = models.CharField(verbose_name='部门名', max_length=32) class UserInfo(models.Model): username = models.CharFiel
阅读全文
摘要:默认解析器 JSONParser, FormParser, MultiPartParser view class UserView(OrPermissionAPIView): from rest_framework.parsers import JSONParser, FormParser from
阅读全文
摘要:路由 urlpatterns = [ path('api/user/', views.UserView.as_view(),name='user'), ] view class UserView(OrPermissionAPIView): def get(self, request, *args,
阅读全文
摘要:路由 urlpatterns = [ path('api/<str:version>/user/', views.UserView.as_view(),name='user'), ] settings REST_FRAMEWORK = { # 版本配置 "DEFAULT_VERSIONING_CLA
阅读全文
摘要:视图 from rest_framework.versioning import QueryParameterVersioning class OrderView(OrPermissionAPIView): versioning_class = QueryParameterVersioning de
阅读全文
摘要:重写SimpleRateThrottle的get_cache_key from rest_framework.throttling import SimpleRateThrottle from django.core.cache import cache as default_cache class
阅读全文
摘要:原权限判断代码 def check_permissions(self, request): """ Check if the request should be permitted. Raises an appropriate exception if the request is not perm
阅读全文
摘要:组件类(返回True为通过) from rest_framework.permissions import BasePermission class DemoPermission(BasePermission): # 自定义失败的返回信息 message = {"status": False, 'c
阅读全文
摘要:建表 from django.db import models class UserInfo(models.Model): username = models.CharField(verbose_name='用户名', max_length=32) password = models.CharFie
阅读全文
摘要:class BaseAuthentication: """ All authentication classes should extend BaseAuthentication. """ def authenticate(self, request): """ 如果子类继承BaseAuthenti
阅读全文
摘要:现象 # 兜底认证,直接失败 class NoAuthentication(BaseAuthentication): def authenticate(self, request): raise AuthenticationFailed('认证失败') class AuthenticationFai
阅读全文