小编Int*_*aek的帖子

如何防止 VS Code 自动从“react-native-web”导入?

当我打字时View,我希望 VS Code 能够自动执行import { View } from 'react-native';,但它确实是这样import { View } from 'react-native-web';。问题是从“react-native-web”导入的任何内容都会产生错误并且似乎永远无法工作。 在此输入图像描述

有哪些程序可以防止这种情况发生?我厌倦了从“react-native”手动导入每个元素。

附言。我正在使用自动导入VS Code 扩展。

react-native visual-studio-code

6
推荐指数
1
解决办法
1899
查看次数

如何区分NextAuth用户登录和注册?

我正在使用 Nextjs 12、NextAuth(Google)、Prisma(MySQL) 构建一个博客平台。当用户首次注册我的平台时,NextAuth 会自动将用户的 google 电子邮件地址和 google 名称保存到我的数据库中。我想让用户在第一次注册时更改他们的昵称。

我如何知道用户是否正在注册或登录?目前在 NextAuth 中,您单击signup()按钮即可进行注册和登录。

next.js prisma next-auth

3
推荐指数
1
解决办法
3009
查看次数

如何访问 prisma 生成的类型?

我正在使用 Next.js Prisma NextAuth。我需要访问我的一个表的 prisma 生成类型,以便我可以从中扩展我的 NextAuth 类型。

我的问题是,如何访问用户模型的类型?

model User {
  id                 String               @id @default(cuid())
  name               String
  nickname           String?              @unique
  email              String               @unique
  emailVerified      DateTime?
  image              String?              @db.VarChar(500)
  title              String?
  description        String?              @db.VarChar(500)
  accounts           Account[]
  sessions           Session[]
  VisitedRestaurants VisitedRestaurants[]
  Reviews            Reviews[]
  ReviewImages       ReviewImages[]
  ReviewLikes        ReviewLikes[]
  ReviewComments     ReviewComments[]
}
Run Code Online (Sandbox Code Playgroud)

typescript prisma next-auth

2
推荐指数
1
解决办法
2182
查看次数

如果ES6的类静态方法的this绑定到类上,为什么this会返回NaN?

class Circle {
    constructor() {
        this.width = 2;
        this.height = 3;
    }
    
    static area() {
        return this.width * this.height
    }
} 

console.log(Circle.area()) // NaN
Run Code Online (Sandbox Code Playgroud)

我了解到 Class 的静态方法将 this 绑定到 Class 本身,而不是 Instance 的新对象。所以我期望 Cicle.area() 返回 6,它来自 (2 * 3)。但实际结果返回 NaN。我找不到原因。

javascript static-methods this ecmascript-6

0
推荐指数
1
解决办法
769
查看次数