”工欲善其事,必先利其器。“—孔子《论语.录灵公》
首页 > 编程 > Wasp:Web 开发中 Django 的 JavaScript 答案

Wasp:Web 开发中 Django 的 JavaScript 答案

发布于2024-09-18
浏览:956

Wasp v Django: Building a full stack application just got a lot easier

Hey, I’m Sam, a backend engineer with a lot of experience with Django. I wanted to make the jump and learn some frontend for a full stack app. I quickly experienced the arduous nature of a React-with-Django project and thought the pain was just part of the development process. However, I came across a very cool new full stack framework called Wasp.

Wasp is an amazing dev tool for full stack applications. Combining things like React, Node.js and Prisma, Wasp allows for development to be expedited in ways never before seen.

In this article, I am going to walk through creating a full stack application in Django versus Wasp to prove the simplicity of Wasp against a very conventional full-stack technology. I am also going to make a react frontend connected to Django. The point is to highlight the inefficiencies, difficulties, and issues that can (and will) arise with Django/react that are made vastly simpler via

This article is not intended as a how to, but I do provide some code as to highlight the exhaustive-nature of a Django app.

Wasp: The JavaScript Answer to Django for Web Development

Part 1: Let There Be Light!

Let’s create some projects and set things up

This part is about the only part where there is significant overlap between Django and Wasp. Both starting from the terminal, let’s make a simple task app (I am assuming you have Django and Wasp installed and in your path).

Django ?

django-admin startproject
python manage.py starapp Todo

Wasp ?

wasp new Todo
wasp start

Now Wasp starts hot out of the gate. Check out the menu you are given below. Wasp can either start a basic app for you, or you can select from a multitude of pre-made templates (including a fully functioning SaaS app) or even use an AI-generated app based on your description!

Wasp: The JavaScript Answer to Django for Web Development

Meanwhile, Django works as a project with apps within the project (again, this is essentially all for backend operations) and there can be many apps to one Django project. Thus, you have to register each app in the Django project settings.

python `manage.py` startapp todo

settings.py:

INSTALLED_APPS [
...
'Todo'
]

Database Time

So now we need a database, and this is another area where Wasp really shines. With Django, we need to create a model in the models.py file. Wasp, meanwhile, uses Prisma as it's ORM which allows us to clearly define necessary fields and make database creation simple in an easy to understand way.

Django ?

models.py:

from django.db import models

class Task(models.Model):
    title = models.CharField(max_length=200)
    completed = models.BooleanField(default=False)

    def __str__(self):
        return self.title

Wasp ?

schema.prisma:

model Task {
    id          Int     @id @default(autoincrement())
    description String
    isDone      Boolean @default(false)
}

Django and Wasp do share similar ways to migrate databases:

Django ?

python manage.py makemigrations
python manage.py migrate

Wasp ?

wasp db migrate-dev

But with Wasp, you can also do some pretty nifty database stuff that Django can't.

Right now we're using SQLite, but how about instantly setting up a development Posgres database? Wasp can do that with:

wasp db start

That's it! With that you've got a docker container running a Postgres instance and it's instantly connected to your Wasp app. ?

Or what if you want to see your database in real time via Prisma’s database studio UI, something not possible without third party extensions with Django. For that, just run:

wasp db studio

Are you starting to see what I mean now?

Routes

Routes in Django and Wasp follow a shomewhat similar pattern. However, if you're familiar with React, then Wasp’s system is far superior.

  • Django works through the backend (views.py, which I will get to later in this article) which do all the CRUD operations. Those view functions are associated to a specific route within an app within a project (I know, a lot), and it can get more complicated if you start using primary keys and IDs. You need to create a urls.py file and direct your specific views file and functions to a route. Those app urls are then connected to the project urls. Phew.

  • Wasp’s way: define a route and direct it to a component.

Django ?

todo/urls.py:

from django.urls import path
from . import views

urlpatterns = [
    path('', views.index, name='index'),
    path('update//', views.updateTask, name='update_task'),
    path('delete//', views.deleteTask, name='delete_task'),
]

./urls.py:

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('todo.urls')),
]

Wasp ?

main.wasp:

route TaskRoute { path: "/", to: TaskPage }
page TaskPage {
  component: import { TaskPage } from "@src/TaskPage"
}

CRUD

Ok, this is where the benefits of Wasp are about to become even more apparent.

Firstly, I am going to revisit the views.py file. This is where magic is going to happen for Django backend. Here is a simple version of what the create, update, and delete functions could look like for our Task/Todo example:

Django ?

todo/views.py:

from django.shortcuts import render, redirect
from .models import Task
from .forms import TaskForm

def index(request):
    tasks = Task.objects.all()
    form = TaskForm()
    if request.method == 'POST':
        form = TaskForm(request.POST)
        if form.is_valid():
            form.save()
        return redirect('/')
    context = {'tasks': tasks, 'form': form}
    return render(request, 'todo/index.html', context)

def updateTask(request, pk):
    task = Task.objects.get(id=pk)
    form = TaskForm(instance=task)
    if request.method == 'POST':
        form = TaskForm(request.POST, instance=task)
        if form.is_valid():
            form.save()
        return redirect('/')
    context = {'form': form}
    return render(request, 'todo/update_task.html', context)

def deleteTask(request, pk):
    task = Task.objects.get(id=pk)
    if request.method == 'POST':
        task.delete()
        return redirect('/')
    context = {'task': task}
    return render(request, 'todo/delete.html', context)

app/forms.py:

from django import forms
from .models import Task

class TaskForm(forms.ModelForm):
    class Meta:
        model = Task
        fields = ['title', 'completed']

Wasp ?

main.wasp:

query getTasks {
  fn: import { getTasks } from "@src/operations",
  // Tell Wasp that this operation affects the `Task` entity. Wasp will automatically
  // refresh the client (cache) with the results of the operation when tasks are modified.
  entities: [Task]
}

action updateTask {
  fn: import { updateTask } from "@src/operations",
  entities: [Task]
}

action deleteTask {
  fn: import { deleteTask } from "@src/operations",
  entities: [Task]
}

operations.js:

export const getTasks = async (args, context) => {
  return context.entities.Task.findMany({
    orderBy: { id: 'asc' },
  })
}

export const updateTask = async ({ id, data }, context) => {
  return context.entities.Task.update({
    where: { id },
    data
  })
}

export const deleteTask = async ({ id }, context) => {
  return context.entities.Task.delete({
    where: { id }
  })
}

So right now, Wasp has a fully functioning backend with middleware configured for you. At this point we can create some React components, and then import and call these operations from the client. That is not the case with Django, unfortunately there is still a lot we need to do to configure React in our app and get things working together, which we will look at below.

Part 2: So you want to use React with Django?

Wasp: The JavaScript Answer to Django for Web Development

At this point we could just create a simple client with HTML and CSS to go with our Django app, but then this wouldn't be a fair comparison, as Wasp is a true full-stack framework and gives you a managed React-NodeJS-Prisma app out-of-the-box. So let's see what we'd have to do to get the same thing set up with Django.

Note that this section is going to highlight Django, so keep in mind that you can skip all the following steps if you just use Wasp. :)

Django ?

First thing’s first. Django needs a REST framework and CORS (Cross Origin Resource Sharing):

pip install djangorestframework
pip install django-cors-headers

Include Rest Framework and Cors Header as installed apps, CORS headers as middleware, and then also set a local host for the react frontend to be able to communicate with the backend (Django) server (again, there is no need to do any of this initial setup in Wasp as it's all handled for you).

settings.py:

INSTALLED_APPS = [
    ...
    'corsheaders',
]

MIDDLEWARE = [
    ...
    'corsheaders.middleware.CorsMiddleware',
    ...
]

CORS_ALLOWED_ORIGINS = [
    'http://localhost:3000',
]

And now a very important step, which is to serialize all the data from Django to be able to work in json format for React frontend.

app/serializers.py:

from rest_framework import serializers
from .models import Task

class TaskSerializer(serializers.ModelSerializer):
    class Meta:
        model = Task
        fields = '__all__'

Now, since we are handling CRUD on the React side, we can change the views.py file:

from rest_framework import viewsets
from .models import Task
from .serializers import TaskSerializer

class TaskViewSet(viewsets.ModelViewSet):
    queryset = Task.objects.all()
    serializer_class = TaskSerializer

And now we need to change both app and project URLS since we have a frontend application on a different url than our backend.

urls.py:

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/', include('todo.urls')),  # Add this line
]
from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import TaskViewSet

router = DefaultRouter()
router.register(r'tasks', TaskViewSet)

urlpatterns = [
    path('', include(router.urls)),
]

By now you should be understanding why I've made the switch to using Wasp when building full-stack apps. Anyways, now we are actually able to make a react component with a Django backend ?

React time

Ok, so now we can actually get back to comparing Wasp and Django.

Django ?

To start, lets create our React app in our Django project:

npx create-react-app frontend

Finally, we can make a component in React. A few things:

  • I am using axios in the Django project here. Wasp comes bundled with React-Query (aka Tanstack Query), so the execution of (CRUD) operations is a lot more elegant and powerful.

  • The api call is to my local server, obviously this will change in development.

  • You can make this many different ways, I tried to keep it simple.

main.jsx:

import React, { useEffect, useState } from 'react';
import axios from 'axios';

const TaskList = () => {
  const [tasks, setTasks] = useState([]);
  const [newTask, setNewTask] = useState('');
  const [editingTask, setEditingTask] = useState(null);

  useEffect(() => {
      fetchTasks();
  }, []);

  const fetchTasks = () => {
    axios.get('http://127.0.0.1:8000/api/tasks/')
      .then(response => {
        setTasks(response.data);
      })
      .catch(error => {
        console.error('There was an error fetching the tasks!', error);
      });
  };

  const handleAddTask = () => {
    if (newTask.trim()) {
      axios.post('http://127.0.0.1:8000/api/tasks/', { title: newTask, completed: false })
        .then(() => {
          setNewTask('');
          fetchTasks();
        })
        .catch(error => {
          console.error('There was an error adding the task!', error);
        });
    }
  };

  const handleUpdateTask = (task) => {
    axios.put(`http://127.0.0.1:8000/api/tasks/${task.id}/`, task)
      .then(() => {
        fetchTasks();
        setEditingTask(null);
      })
      .catch(error => {
        console.error('There was an error updating the task!', error);
      });
  };

  const handleDeleteTask = (taskId) => {
    axios.delete(`http://127.0.0.1:8000/api/tasks/${taskId}/`)
      .then(() => {
        fetchTasks();
      })
      .catch(error => {
        console.error('There was an error deleting the task!', error);
      });
  };

  const handleEditTask = (task) => {
    setEditingTask(task);
  };

  const handleChange = (e) => {
    setNewTask(e.target.value);
  };

  const handleEditChange = (e) => {
    setEditingTask({ ...editingTask, title: e.target.value });
  };

  const handleEditCompleteToggle = () => {
    setEditingTask({ ...editingTask, completed: !editingTask.completed });
  };

  return (
    

To-Do List

    {tasks.map(task => (
  • {editingTask && editingTask.id === task.id ? (
    ) : (
    {task.title} - {task.completed ? 'Completed' : 'Incomplete'}
    )}
  • ))}
); }; export default TaskList;

Wasp ?

And here's the Wasp React client for comparison. Take note how we're able to import the operations we defined earlier and call them here easily on the client with less configuration than the Django app. We also get the built-in caching power of the useQuery hook, as well as the ability to pass in our authenticated user as a prop (we'll get into this more below).

Main.jsx:

import React, { FormEventHandler, FormEvent } from "react";
import { type Task } from "wasp/entities";
import { type AuthUser, getUsername } from "wasp/auth";
import { logout } from "wasp/client/auth";
import { createTask, updateTask, deleteTasks, useQuery, getTasks } from "wasp/client/operations";
import waspLogo from "./waspLogo.png";

import "./Main.css";

export const MainPage = ({ user }) => {
  const { data: tasks, isLoading, error } = useQuery(getTasks);

  if (isLoading) return "Loading...";
  if (error) return "Error: "   error;

  const completed = tasks?.filter((task) => task.isDone).map((task) => task.id);

  return (
    
wasp logo {user && user.identities.username && (

{user.identities.username.id} {`'s tasks :)`}

)} {tasks && }
); }; function Todo({ id, isDone, description }) { const handleIsDoneChange = async ( event ) => { try { await updateTask({ id, isDone: event.currentTarget.checked, }); } catch (err: any) { window.alert("Error while updating task " err?.message); } }; return (
  • {description}
  • ); } function TasksList({ tasks }) { if (tasks.length === 0) return

    No tasks yet.

    ; return (
      {tasks.map((task, idx) => ( ))}
    ); } function NewTaskForm() { const handleSubmit = async (event) => { event.preventDefault(); try { const description = event.currentTarget.description.value; console.log(description); event.currentTarget.reset(); await createTask({ description }); } catch (err: any) { window.alert("Error: " err?.message); } }; return (
    ); }

    Very nice! In the Wasp app you can see how much easier it is to call the server-side code via Wasp operations. Plus, Wasp gives you the added benefit of refreshing the client-side cache for the Entity that's referenced in the operation definition (in this case Task). And the cherry on top is how easy it is to pass the authenticated user to the component, something we haven't even touched on in the Django app, and which we will talk about more below.

    Part 3: Auth with Django? No way, José

    Wasp: The JavaScript Answer to Django for Web Development

    So we already started to get a feel in the above code for how simple it is to pass an authenticated user around in Wasp. But how do we actually go about implementing full-stack Authentication in Wasp and Django.

    This is one of Wasp’s biggest advantages. It couldn't be easier or more intuitive. On the other hand, the Django implementation is so long and complicated I'm not going to even bother showing you the code and I'll just list out the stps instead;

    Wasp ?

    main.wasp:

    app TodoApp {
      wasp: {
        version: "^0.14.0"
      },
    
      title: "Todo App",
    
      auth: {
        userEntity: User,
        methods: {
          usernameAndPassword: {}
        }
      }
    
      //...
    

    And that's all it takes to implement full-stack Auth with Wasp! But that's just one example, you can also add other auth methods easily, like google: {}, gitHub: {} and discord: {} social auth, after configuring the apps and adding your environment variables.

    Wasp allows you to get building without worrying about so many things. I don’t need to worry about password hashing, multiple projects and apps, CORS headers, etc. I just need to add a couple lines of code.

    Wasp just makes sense.

    Wasp: The JavaScript Answer to Django for Web Development

    Django ?

    Let's check out what it takes to add a simple username and password auth implementation to a Django app (remember, this isn't even the code, just a checklist!):

    Install Necessary Packages:

    • Use pip to install djangorestframework, djoser, and djangorestframework-simplejwt for Django.
    • Use npm to install axios and jwt-decode for React.

    Update Django Settings:

    • Add required apps (rest_framework, djoser, corsheaders, and your Django app) to INSTALLED_APPS.
    • Configure middleware to include CorsMiddleware.
    • Set up Django REST Framework settings for authentication and permissions.
    • Configure SimpleJWT settings for token expiration and authorization header types.

    Set Up URL Routing:

    • Include the djoser URLs for authentication and JWT endpoints in Django’s urls.py.

    Implement Authentication Context in React:

    • Create an authentication context in React to manage login state and tokens.
    • Provide methods for logging in and out, and store tokens in local storage.

    Create Login Component in React:

    • Build a login form component in React that allows users to enter their credentials and authenticate using the Django backend.

    Protect React Routes and Components:

    • Use React Router to protect routes that require authentication.
    • Ensure that API requests include the JWT token for authenticated endpoints.

    Implement Task Update and Delete Functionality:

    • Add methods in the React components to handle updating and deleting tasks.
    • Use axios to make PUT and DELETE requests to the Django API.

    Add Authentication to Django Views:

    • Ensure that Django views and endpoints require authentication.
    • Use Django REST Framework permissions to protect API endpoints.

    One Final Thing

    I just want to highlight one more aspect of Wasp that I really love. In Django, we're completely responsible for dealing with all the boilerplate code when setting up a new app. In other words, we have to set up new apps from scratch every time (even if it's been done before a million times by us and other devs). But with Wasp we can scaffold a new app template in a number of ways to really jump start the development process.

    Let's check out these other ways to get a full-stack app started in Wasp.

    Way #1: Straight Outta Terminal

    A simple wasp new in the terminal shows numerous starting options and app templates. If I really want to make a todo app for example, well there you have it, option 2.

    Right out of the box you have a to-do application with authentication, CRUD functionality, and some basic styling. All of this is ready to be amended for your specific use case.

    Or what if you want to turn code into money? Well, you can also get a fully functioning SaaS app. Interested in the latest AI offereings? You also have a vector embeddings template, or an AI full-stack app protoyper! 5 options that save you from having to write a ton of boilerplate code.

    Wasp: The JavaScript Answer to Django for Web Development

    Way #2: Mage.ai (Free!)

    Just throw a name, prompt, and select a few of your desired settings and boom, you get a fully functioning prototype app. From here you can use other other AI tools, like Cursor's AI code editor, to generate new features and help you debug!

    Wasp: The JavaScript Answer to Django for Web Development

    ? Note that the Mage functionality is also achievable via the terminal ("ai-generated"), but you need to provide your own open-ai api key for it to work.

    Can you show us your support?

    Wasp: The JavaScript Answer to Django for Web Development

    Are you interested in more content like this? Sign up for our newsletter and give us a star on GitHub! We need your support to keep pushing our projects forward ?

    ⭐️ Star Wasp on GitHub ?

    Conclusion

    So there you have it. As I said in the beginning, coming from Django I was amazed how easy it was to build full-stack apps with Wasp, which is what inspired me to write this article.

    Hopefully I was able to show you why breaking away from Django in favor of Wasp can be beneficial in time, energy, and emotion.

    版本声明 本文转载于:https://dev.to/wasp/wasp-the-javascript-answer-to-django-for-web-development-199m?1如有侵犯,请联系[email protected]删除
    最新教程 更多>
    • 为什么我的 canvas.toDataURL() 没有保存我的图像?
      为什么我的 canvas.toDataURL() 没有保存我的图像?
      Resolving Image Saving Issues with canvas.toDataURL()When attempting to utilize canvas.toDataURL() to save a canvas as an image, you may encounter dif...
      编程 发布于2024-11-07
    • Node.js 中的新增功能
      Node.js 中的新增功能
      TL;DR: 让我们探索 Node.js 22 的主要功能,包括 ECMAScript 模块支持和 V8 引擎更新。此版本引入了 Maglev 编译器和内置 WebSocket 客户端,以增强性能和实时通信。还涵盖了测试、调试和文件系统管理方面的改进。 Node.js 22 将于 10 月进入 LT...
      编程 发布于2024-11-07
    • 了解 MongoDB 的distinct() 操作:实用指南
      了解 MongoDB 的distinct() 操作:实用指南
      MongoDB 的distinct() 操作是一个强大的工具,用于从集合中的指定字段检索唯一值。本指南将帮助您了解distinct() 的用途、使用它的原因和时间,以及如何在 MongoDB 查询中有效地实现它。 什么是distinct()? distinct() 方法返回集合或集合...
      编程 发布于2024-11-07
    • 为什么 JavaScript 中的“0”在比较中为 False,而在“if”语句中为 True?
      为什么 JavaScript 中的“0”在比较中为 False,而在“if”语句中为 True?
      揭开 JavaScript 的悖论:为什么“0”在比较中为假,但在 If 语句中为假在 JavaScript 中,原语 " 的行为0”给开发者带来了困惑。虽然诸如“==”之类的逻辑运算符将“0”等同于假,但“0”在“if”条件下表现为真。比较悖论代码下面演示了比较悖论:"0&qu...
      编程 发布于2024-11-07
    • GitHub Copilot 有其怪癖
      GitHub Copilot 有其怪癖
      过去 4 个月我一直在将 GitHub Copilot 与我们的生产代码库一起使用,以下是我的一些想法: 好的: 解释复杂代码:它非常适合分解棘手的代码片段或业务逻辑并正确解释它们。 单元测试:非常擅长编写单元测试并快速生成多个基于场景的测试用例。 代码片段:它可以轻松地为通用用例生成有用的代码片段...
      编程 发布于2024-11-07
    • 静态类或实例化类:什么时候应该选择哪个?
      静态类或实例化类:什么时候应该选择哪个?
      在静态类和实例化类之间做出选择:概述在 PHP 中设计软件应用程序时,开发人员经常面临在使用静态类或实例化对象。这个决定可能会对程序的结构、性能和可测试性产生重大影响。何时使用静态类静态类适用于对象不具备静态类的场景独特的数据,只需要访问共享功能。例如,用于将 BB 代码转换为 HTML 的实用程序...
      编程 发布于2024-11-07
    • ⚠️ 在 JavaScript 中使用 `var` 的隐藏危险:为什么是时候继续前进了
      ⚠️ 在 JavaScript 中使用 `var` 的隐藏危险:为什么是时候继续前进了
      关键字 var 多年来一直是 JavaScript 中声明变量的默认方式。但是,它有一些怪癖和陷阱,可能会导致代码出现意外行为。现代替代方案(如 let 和 const)解决了许多此类问题,使它们成为大多数情况下声明变量的首选。 1️⃣ 提升:var 在不知不觉中声明变量! ?解释:...
      编程 发布于2024-11-07
    • PDO::MYSQL_ATTR_INIT_COMMAND 需要“SET CHARACTER SET utf8”吗?
      PDO::MYSQL_ATTR_INIT_COMMAND 需要“SET CHARACTER SET utf8”吗?
      在带有“PDO::MYSQL_ATTR_INIT_COMMAND”的 PDO 中“SET CHARACTER SET utf8”是否必要?在 PHP 和 MySQL 中,“SET NAMES” utf8”和“SET CHARACTER SET utf8”通常在使用 UTF-8 编码时使用。但是,当使...
      编程 发布于2024-11-07
    • 为什么使用Password_Hash函数时哈希值会变化?
      为什么使用Password_Hash函数时哈希值会变化?
      了解Password_Hash函数中不同的哈希值在开发安全认证系统时,开发人员经常会遇到使用password_hash获取不同密码哈希值的困惑功能。为了阐明此行为并确保正确的密码验证,让我们分析此函数背后的机制。密码加盐:有意的功能password_hash 函数有意生成唯一的盐它对每个密码进行哈希...
      编程 发布于2024-11-07
    • 为什么与谷歌竞争并不疯狂
      为什么与谷歌竞争并不疯狂
      大家好,我是 Antonio,Litlyx 的首席执行官,我们的对手是一些巨头! Microsoft Clarity、Google Analytics、MixPanel...它们是分析领域的重要参与者。当人们听说一家初创公司正在与如此知名的公司合作时,他们常常会感到惊讶。但让我们看看为什么与谷歌这样...
      编程 发布于2024-11-07
    • 如何在 Java Streams 中高效地将对象列表转换为可选对象?
      如何在 Java Streams 中高效地将对象列表转换为可选对象?
      使用 Java 8 的可选和 Stream::flatMap 变得简洁使用 Java 8 流时,将 List 转换为可选 并有效地提取第一个 Other 值可能是一个挑战。虽然 flatMap 通常需要返回流,但可选的 Stream() 的缺失使问题变得复杂。Java 16 解决方案Java 16 ...
      编程 发布于2024-11-07
    • 避免前端开发失败:编写干净代码的行之有效的实践
      避免前端开发失败:编写干净代码的行之有效的实践
      介绍 您是否曾因看似无法理清或扩展的凌乱代码而感到不知所措?如果你有,那么你并不孤单。许多开发人员面临着维护干净的代码库的挑战,这对于项目的长期成功和可扩展性至关重要。让我们探索一些有效的策略来保持代码可管理性和项目顺利运行。 了解基础知识:什么是干净代码? 干净的...
      编程 发布于2024-11-07
    • 如何访问Python字典中的第一个和第N个键值对?
      如何访问Python字典中的第一个和第N个键值对?
      获取 Python 字典中的第一个条目使用数字索引(如颜色[0])对字典进行索引可能会导致 KeyError 异常。从 Python 3.7 开始,字典保留插入顺序,使我们能够像有序集合一样使用它们。获取第一个键和值要获取字典中的第一个键和值,我们可以使用以下方法:列表转换:使用 list(dict...
      编程 发布于2024-11-07
    • 使用 cProfile 和 PyPy 模块优化 Python 代码:完整指南
      使用 cProfile 和 PyPy 模块优化 Python 代码:完整指南
      介绍 作为 Python 开发人员,我们通常先关注让代码正常运行,然后再担心优化它。然而,在处理大规模应用程序或性能关键型代码时,优化变得至关重要。在这篇文章中,我们将介绍两个可用于优化 Python 代码的强大工具:cProfile 模块和 PyPy 解释器。 在这篇文章的结尾,...
      编程 发布于2024-11-07
    • 上周我学到了什么(
      上周我学到了什么(
      原生 JavaScript 中的反应性 – 使用代理模式在应用程序状态更改时触发事件。 (前端大师课程 - “你可能不需要框架”) throw new Error("Error!") 不能在三元中使用(至少不能用作 'else' 部分。三元运算符的最后一部分...
      编程 发布于2024-11-07

    免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。

    Copyright© 2022 湘ICP备2022001581号-3