小编woo*_*oof的帖子

安装 npm react-facebook-login 时出现“ERESOLVE 无法解析依赖树”

尝试npm react-facebook-login在我的 React 应用程序中安装,但我不断收到依赖项错误?这听起来很可怕,我不想强​​制安装将来可能会损坏的东西。我是 javascript 新手,我应该采取哪些方法?

我已经尝试清除我的 npm 缓存并删除节点模块并再次安装它们,但是我仍然收到此错误。

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: buckets@0.1.0
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR!   react@"^17.0.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.0.0" from react-facebook-login@4.1.1
npm ERR! node_modules/react-facebook-login
npm ERR!   react-facebook-login@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

14
推荐指数
4
解决办法
2万
查看次数

如何将 pandas NaT 日期时间值正确插入到我的 postgresql 表中

我正在将数据帧批量插入到我的 postgres dB 中。我的数据框中的某些列是具有NaT空值的日期类型。PostgreSQL 不支持它,我尝试NaT用其他 NULL 类型标识替换(使用 pandas),但这在我的插入过程中不起作用。

我曾经df = df.where(pd.notnull(df), 'None')替换了所有NaTs,由于数据类型问题而不断出现的错误示例。

Error: invalid input syntax for type date: "None"
LINE 1: ...0,1.68757,'2022-11-30T00:29:59.679000'::timestamp,'None','20...
Run Code Online (Sandbox Code Playgroud)

我的驱动程序和插入语句到 postgresql dB:

def execute_values(conn, df, table):
    """
    Using psycopg2.extras.execute_values() to insert the dataframe
    """
    # Create a list of tupples from the dataframe values
    tuples = [tuple(x) for x in df.to_numpy()]
    # Comma-separated dataframe columns
    cols = ','.join(list(df.columns))
    # SQL quert to execute
    query  = "INSERT INTO %s(%s) …
Run Code Online (Sandbox Code Playgroud)

python postgresql sqlalchemy psycopg2 pandas

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

TailwindCC:无下划线类不适用于我的 <a> 标记?

我试图避免在我的<a>标签下有下划线。我已经按照文档添加了该类"no-underline",但我的链接下仍然有下划线?我添加了下面使用的代码:

<div
  class="
    my-3
    flex flex-wrap
    -m-1
    text-center
    justify-center
    items-center
    no-underline
  "
>
  <div class="m-auto">
    {% for tag in tags %}
    <a
      href="{% routablepageurl blog_page 'post_by_tag' tag.slug %}"
      class="no-underline"
    >
      <span
        class="
          font-mono
          m-1
          bg-gray-200
          hover:bg-gray-300
          rounded-full
          px-2
          py-1
          font-bold
          text-sm
          leading-loose
          cursor-pointer
          shadow-lg
          no-underline
        "
        >{{ tag }}</span
      >
    </a>
    {% empty %} No tags yet {% endfor %}
  </div>
</div>

Thanks for the help!

Run Code Online (Sandbox Code Playgroud)

html css tailwind-css

9
推荐指数
1
解决办法
4870
查看次数

反应 - 错误:无效的挂钩调用。钩子只能在函数组件的主体内部调用。我的语法有什么问题吗?

提供一些背景知识:

\n

我正在尝试构建一个登录表单页面函数来检测用户是否已经登录。如果他们已登录,则会出现一个按钮,提示用户注销。就像这样: {user ? userLoggedInAlert() : SignIn()}如果user为 True,则出现该按钮,如果user为 false,则他们会收到用于登录身份验证的用户名和密码表单。

\n

我已经确定了所有功能。\n但是,当我按下按钮注销用户时,我收到此错误:

\n
\xc3\x97\nError: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs material-ui

8
推荐指数
1
解决办法
5万
查看次数

如何将 MUI 主题颜色添加到内联样式?

假设我下面有这些选项卡。如何使用内联 CSS 的 MUIprimarysecondary颜色?我想使用调色板中的颜色来自定义它。

            <Tabs
              value={value}
              onChange={handleChange}
              variant='fullWidth'
              aria-label="simple tabs example"
              className="tableViewTabs"
              centered
              color="primary"
              // inkBarStyle={{backgroundColor: '#68C222', width: '33.3%'}}
              // tabItemContainerStyle={{backgroundColor: '#FFFFFF', width: '30%'}} 
          >
                <Tab
                  icon={<GradeIcon/>}
                  {...a11yProps(0)}
                  disableFocusRipple={true}
                  disableRipple = {true}
                  color="primary"
                  style={{ textTransform: "none", fontSize: 16, color: value === 0 ? "" : "" }}
                />
                <Tab
                    icon={<ViewAgendaIcon />}
                    {...a11yProps(1)}
                    disableFocusRipple={true}
                disableRipple={true}
                style={{ textTransform: "none", fontSize: 16, fontWeight: value === 1 ? "bold" : "" }} 
                />
                <Tab
                    icon={<AppsIcon />}
                    {...a11yProps(2)}
                    disableFocusRipple = {true} …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs material-ui

7
推荐指数
1
解决办法
5356
查看次数

“具有动态格式字符串且没有其他参数的 printf 样式函数应该使用 print 样式函数”是什么意思?

具有动态格式字符串且没有其他参数的 printf 样式函数应使用 print 样式函数

我的 VScode 不断fmt.Fprintf(w, prettyJSON.String())用上述警告突出显示我的语句。不确定这意味着什么,或者如何解决。这是我如何使用的示例Fprintf()

func (s *Server) getWorkSpaces(w http.ResponseWriter, r *http.Request) {
    client := &http.Client{}
    var prettyJSON bytes.Buffer
    req, err := http.NewRequest("GET", "url.com", nil)
    if err != nil {
        // if there was an error parsing the request, return an error to user and quit function
        responses.ERROR(w, http.StatusBadRequest, fmt.Errorf("unable to read request body: %v", err))
        return
    }


    resp, err := client.Do(req)
    if err != nil {
        // if there was an …
Run Code Online (Sandbox Code Playgroud)

go

7
推荐指数
1
解决办法
5861
查看次数

为什么我的 React 生产应用程序无法在移动浏览器上运行?

我目前已经部署了我的网络应用程序,它在桌面上运行得很好。这个问题完全是移动的。我能够在主页上发生 GET 调用 (axios) 之前在移动浏览器上加载网站一秒钟,然后移动浏览器挂在白色页面上。

我的后端是用 Django 构建的。我还使用 Django 来帮助从npm run build.

这是我的 package.json:

{
  "name": "buckets",
  "homepage": ".",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.11.2",
    "@material-ui/icons": "^4.11.2",
    "@material-ui/lab": "^4.0.0-alpha.57",
    "@reduxjs/toolkit": "^1.5.0",
    "@testing-library/jest-dom": "^5.11.6",
    "@testing-library/react": "^11.2.2",
    "@testing-library/user-event": "^12.6.0",
    "axios": "^0.21.1",
    "chartist": "^0.10.1",
    "react": "^17.0.1",
    "react-chartist": "^0.14.4",
    "react-dom": "^17.0.1",
    "react-hook-form": "^6.14.2",
    "react-redux": "^7.2.2",
    "react-router-dom": "^5.2.0",
    "react-scripts": "^4.0.3",
    "react-scroll": "^1.8.2",
    "react-window": "^1.8.6",
    "redux": "^4.0.5",
    "redux-persist": "^6.0.0",
    "redux-thunk": "^2.3.0",
    "web-vitals": "^0.2.4"
  },
  "scripts": {
    "start": "PORT=4000 react-scripts start",
    "build": "react-scripts …
Run Code Online (Sandbox Code Playgroud)

javascript mobile reactjs axios

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

即使在设置中进行了配置,Django 也找不到我的模板目录?

我正在尝试为 django 邮件模块使用 HTML 模板。我当前的问题是我收到此错误:

django.template.exceptions.TemplateDoesNotExist
Run Code Online (Sandbox Code Playgroud)

当我尝试在我的应用程序中渲染 HTML 时,调用users

html = render_to_string('email/email_confirm.html', context)
Run Code Online (Sandbox Code Playgroud)

这是我的文件夹布局,我的应用程序称为用户,我的项目设置位于/core. 我的模板位于 BASE_DIR。

在此处输入图片说明

这是我在设置中的模板代码:


TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'social_django.context_processors.backends',
                'social_django.context_processors.login_redirect',
            ],
        },
    },
]

Run Code Online (Sandbox Code Playgroud)

如何让 Django 正确找到模板文件夹?我已经连接了所有应用程序并且数据工作正常。这严格来说是模板路径问题。

编辑:我保留了我的APP_DIRS= True 并将模板/电子邮件文件夹移动到用户应用程序文件夹中。

django 还是找不到模板?

这是有问题的 View.py:


class CustomUserCreate(APIView):
    permission_classes = [AllowAny]

    def post(self, request, format='json'):
        serializer = CustomUserSerializer(data=request.data)

        if serializer.is_valid():
            user = serializer.save()
            if user:
                # GENERATE EMAIL …
Run Code Online (Sandbox Code Playgroud)

python django

5
推荐指数
1
解决办法
211
查看次数

React - 您为选择组件提供了超出范围的值“未定义”

我正在创建一个材质-UI 对话,将posts数据传输到我的 API。我的后端数据库中的字段之一是二进制的,仅包含两个可能的选项。我如何在下面的对话代码中反映这一点?

这是我的 Fulltrace Back 错误:

undefinedMaterial-UI:您为 select (name="category") 组件提供了超出范围的值。考虑提供与可用选项之一或 '' 匹配的值。可用值为personal, social

该特定字段的可能选项是personalsocial

我尝试这样做,让我的对话推动正确的反应:

<MenuItem value={'personal'}> personal </MenuItem>
<MenuItem value={'social'}> social </MenuItem>
Run Code Online (Sandbox Code Playgroud)

但这不起作用,我明白为什么。只是不确定现在如何解决该错误,因为我一般对 React/JS 不太了解。

export default function CreateBucket() {
    const [open, setOpen] = React.useState(false);

    const handleClickOpen = () => {
      setOpen(true);
    };
  
    const handleClose = () => {
      setOpen(false);
    };
  

    const history = useHistory();
    const initialFormData = Object.freeze({
        name: '',
        category: '',
        about: '',
    });

    const [formData, …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs material-ui

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

如何通过 Django 正确地服务我的 React 生产构建。当前配置当前存在 MIME 类型问题

我正在尝试将我的 React/django Web 应用程序部署到 linux-VM Droplet。我没有使用 webpack 来处理 JS 内容。相反,我npm run build通过 CDN 子域、数字海洋 s3 存储桶提供静态文件。

\n

我能够将python manage.py collectstatic我的 React 生产构建文件夹推送到 CDN。

\n

当我访问我的生产网站时,它当前仅加载一个空白页面,其中包含以下控制台错误:

\n
Refused to apply style from \'https://www.my_website_URL.com/static/css/main.ce8d6426.chunk.css\' because its MIME type (\'text/html\') is not a supported stylesheet MIME type, and strict MIME checking is enabled.\n\nRefused to execute script from \'https://www.my_website_URL.com/static/js/2.ca12ac54.chunk.js\' because its MIME type (\'text/html\') is not executable, and strict MIME type checking is enabled.\n\nRefused to execute script from \'https://www.my_website_URL.com/static/js/main.220624ac.chunk.js\' because …
Run Code Online (Sandbox Code Playgroud)

javascript python django reactjs digital-ocean

4
推荐指数
1
解决办法
2065
查看次数

Terraform - 如何在模块内引用我的输出?

尝试在 main.tf 中引用我的输出之一时遇到问题。我正在尝试使用实例的公共 IP 地址的输出来尝试使用remote-exec. 以下是文件:

\n

主.tf

\n
module "subnetwork" {\n  source = "../modules/uc1" \n  env                   = "${var.var_env}"\n  company               = "${var.var_company}"\n  depends_on = [\n    module.vpc\n  ]\n\n}\n\noutput "server_private_ip" {\n  value = google_compute_instance.default.network_interface[0].network_ip\n}\n\noutput "server_public_ip" {\n  value = google_compute_instance.default.network_interface[0].access_config[0].nat_ip\n}\n
Run Code Online (Sandbox Code Playgroud)\n

../模块/uc1:

\n
resource "google_compute_instance" "default" {\n  name         = "${format("%s","${var.company}-${var.tester}-${var.env}-${var.var_region_name}-instance1")}"\n  machine_type = "${var.var_machine_type}"\n  zone         = "${var.var_zone_name}"\n\n  tags = ["http", "https", "ssh"]\n\n  boot_disk {\n    initialize_params {\n      image = "${var.var_instance_image}"\n    }\n  }\n\n\n  metadata = {\n    ssh-keys = "root:${file(var.var_ssh)}"\n  }\n\n    \n  provisioner "remote-exec" {\n\n …
Run Code Online (Sandbox Code Playgroud)

terraform terraform-provider-gcp

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

如何在排序依据函数中处理空值?

我有一个 React 表,它具有可按 desc 和 asc 值排序的标题。它将字符串值解析为数字以进行排序。但是,当我的numeric(x)函数满足数据集中的值时,它无法交付null

这是错误:TypeError: Cannot read property 'slice' of null

下面是我的函数,我还添加了有关如何实现numeric排序Comparator()的代码

function numeric(x) {
    const val = parseFloat(x);
    if (isNaN(val)) {
      return parseFloat(x.slice(1));
    } else {
      return val;
    }
  }

function descendingComparator(a, b, orderBy)
{
    const numericA = numeric(a[orderBy]);
    const numericB = numeric(b[orderBy]);
    if (numericB < numericA){
        return -1
    }
    if (numericB > numericA){
        return 1
    }
    return 0
}
Run Code Online (Sandbox Code Playgroud)

我应该如何处理数字函数中的空值?实际上,当按 asc 和 desc 排序时,它们应该被忽略并放置在啄序的底部。

编辑:输入 x …

javascript json reactjs

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