小编tak*_*aks的帖子

获取错误:“() => () => boolean”类型的参数不可分配给“EffectCallback”类型的参数

我是打字稿的新手,当我尝试useEffect在 react 中使用打字稿时出现错误Argument of type '() => () => boolean' is not assignable to parameter of type 'EffectCallback'.,任何人都可以帮助我为什么会出现此错误?我把我的代码放在这里,任何帮助将不胜感激,

const useIsMounted = () => {
        const isMounted = React.useRef(false);
        React.useEffect(() => {
          isMounted.current = true;
          return () => isMounted.current = false;
        }, []);
        return isMounted;
    };
Run Code Online (Sandbox Code Playgroud)

javascript typescript reactjs

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

如何在下一个js中设置默认页面?

我是新来的next.js,在next.js默认页面中index.js,我想将其路径更改为login,任何人都可以帮我怎么做吗?现在我正在使用,Router.push('/login'); 但它产生了闪烁问题,有人可以帮助解决这个问题吗?

import Head from 'next/head'
import styles from '../styles/Home.module.css'
import Router from 'next/router'
import React, { useEffect } from "react";
import { Redirect } from 'react-router';


export default function Home(props) {
  useEffect(() => {
    const { pathname } = Router
    if (pathname == '/') {
      Router.push('/login');
    }
  }, [props]);

  return ''
}
Run Code Online (Sandbox Code Playgroud)

reactjs next.js

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

为什么我无法更新节点js中的环境变量

我想在节点js中更新我的环境变量,但我无法更新它的环境变量,我尝试过console.log(process.env.DB_HOST),但仍然得到旧值,在这里我添加了我的整个代码,任何人都可以查看它,并且帮我解决这个问题,

function exec_api() { 
    return new Promise(async function (resolve) {
        const execSync = require('child_process').exec;
        //let child_process_obj = execSync('DB_HOST='+process.env.UNITTEST_DB_HOST+' DB_DATABASE='+process.env.UNITTEST_DB_DATABASE+'  DB_USERNAME='+process.env.UNITTEST_DB_USERNAME+' DB_PASSWORD='+process.env.UNITTEST_DB_PASSWORD+'  PORT='+process.env.UNITTEST_SERVICE_PORT+' ./node_modules/.bin/nodemon main.js'); 
        await execSync('export DB_HOST=' + process.env.UNITTEST_DB_HOST);
        await execSync('export DB_DATABASE=' + process.env.UNITTEST_DB_DATABASE);
        await execSync('export DB_USERNAME=' + process.env.UNITTEST_DB_USERNAME);
        await execSync('export DB_PASSWORD=' + process.env.UNITTEST_DB_PASSWORD);
        await execSync('export PORT=' + process.env.UNITTEST_API_BACKEND_PORT);
        let child_process_obj = await execSync('node main.js');
        unittest_api_backend_process_id = child_process_obj.pid;
        resolve(true);
    });
}
Run Code Online (Sandbox Code Playgroud)

node.js node-modules

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

收到错误:您无法在 PaymentMethod 创建期间将 PaymentMethod 附加到客户。在定期付​​款意向条中

我正在研究定期付款意向,当我尝试这样做时Charge the saved card later Server-side,我收到以下回复:

Array
(
    [error] => Array
        (
            [message] => You cannot attach a PaymentMethod to a Customer during PaymentMethod creation. Please instead create the PaymentMethod and then attach it using the attachment method of the PaymentMethods API.
            [type] => invalid_request_error
        )

)
Run Code Online (Sandbox Code Playgroud)

为此我使用了curl方法

curl https://api.stripe.com/v1/payment_methods \
  -u ********: \
  -d customer="{{CUSTOMER_ID}}" \
  -d type=card
Run Code Online (Sandbox Code Playgroud)

谁能帮我解决这个问题吗?我已经参考了这个页面

https://stripe.com/docs/payments/save-and-reuse
Run Code Online (Sandbox Code Playgroud)

stripe-payments

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

如何从 json 获取带有动态变量的对象值

我想从 JSON 中获取对象字段的值。我有一个动态变量let check_permission_key = 'ratingscalename';和一个 JSON

let overwrite_key = {
  studentimage: 'student',
  ratingscalename: 'rating-scale-name',
  ratingscale: 'rating-scale-name',
  capturesettingset: 'capture-setting-set',
  capturesetting: 'capture-setting-set',
  eventlog: 'event-log',
  goalcategorie: 'goal-category',
  userimage: 'user',
  datasheetlink: 'datasheet',
  datasheetgoal: 'datasheet',
};

let get_value = overwrite_key.check_permission_key;
Run Code Online (Sandbox Code Playgroud)

所以我正在像这样获取数据,但它不起作用,有人可以帮我解决这个问题吗?

javascript jquery node.js

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

收到错误:aws 服务器中的设备上没有剩余空间

我一个月前创建了实例,它工作正常,但突然它停止工作,这很奇怪,当我使用 ssh 登录时,我使用命令df -h,我可以其中一些进程显示 100%,看起来像我的原因遇到这个问题:No space left on device我尝试附加卷,但仍然无法正常工作,任何人都可以帮我解决这个问题吗?在这里我攻击了我的过程

Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           787M   80M  707M  11% /run
/dev/nvme0n1p1  7.7G  7.7G     0 100% /
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/loop0       29M   29M     0 100% /snap/amazon-ssm-agent/2012
/dev/loop1       97M   97M     0 100% /snap/core/9436
/dev/loop2       18M   18M     0 100% /snap/amazon-ssm-agent/1566
/dev/loop3       98M   98M     0 100% /snap/core/9289 …
Run Code Online (Sandbox Code Playgroud)

amazon-ec2 amazon-web-services

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

当我使用 ETH 部署 NFT 时出现错误

我是 NFT 新手,我正在尝试创建测试 NFT,当我尝试部署该 NFT 时,我收到此错误,insufficient funds for intrinsic transaction cost即使我的帐户中有 1 ETH 余额,但我已附加了它的完整代码,可以有人请帮助我,如何解决这个问题?MyNFT.sol

//Contract based on [https://docs.openzeppelin.com/contracts/3.x/erc721](https://docs.openzeppelin.com/contracts/3.x/erc721)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";

contract MyNFT is ERC721URIStorage, Ownable {   
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

    constructor() ERC721("MyNFT", "NFT") {}

    function mintNFT(address recipient, string memory tokenURI)
        public onlyOwner
        returns (uint256)
    {
        _tokenIds.increment();

        uint256 newItemId = _tokenIds.current();
        _mint(recipient, newItemId);
        _setTokenURI(newItemId, tokenURI);

        return newItemId;
    }
}
Run Code Online (Sandbox Code Playgroud)

安全帽.config.js

/**

* @type import('hardhat/config').HardhatUserConfig …
Run Code Online (Sandbox Code Playgroud)

ethereum solidity openzeppelin nft hardhat

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

出现错误:解析方法过度指定。指定回调*或*返回 Promise;不是都

当我运行我的函数时,它给了我错误:Resolution method is overspecified. Specify a callback *or* return a Promise; not both.任何人都可以检查我的代码,并帮助解决这个问题吗?我在这里放置了完整的代码

it('Get Organizations', async function (done) {
        let user_permission = await commonService.getuserPermission(logged_in_user_id,'organizations','findAll');
        let api_status = 404;
        if(user_permission) { 
            api_status = 200;
        }

        let current_token = currentResponse['token'];
        old_unique_token = current_token;

        chai.request(app)
            .post('entities')
            .set('Content-Type', 'application/json')
            .set('vrc-access-token', current_token)
            .send({ "key": "organizations", "operation": "findAll" })
            .end(function (err, res) {
                currentResponse = res.body;
                expect(err).to.be.null;
                expect(res).to.have.status(api_status);
                done();
            }); 

    });
Run Code Online (Sandbox Code Playgroud)

mocha.js node.js node-modules chai

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

收到错误:chromedriver 安装失败错误 eacces 权限被拒绝 mkdir

当我尝试使用npm install chromedriver --chromedriver-force-downloadNode js 安装 Chrome 驱动程序时,出现以下错误:chromedriver installation failed error eacces permission denied mkdir

我已经申请了完全许可777,但仍然收到此错误,有人可以帮助我为什么会收到此错误吗?

我使用了这些命令:

1) npm i chromedriver

2) Force Download : npm install chromedriver --chromedriver-force-download
Run Code Online (Sandbox Code Playgroud)

mocha.js node.js selenium-chromedriver node-modules selenium-webdriver

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

出现错误 找不到存储过程“sp_configure”。在 sql 服务器中

我需要更改并行度,但是当我运行时出现错误

Could not find stored procedure 'sp_configure'.
Run Code Online (Sandbox Code Playgroud)

这是我的脚本

USE test;  
GO   
EXEC sp_configure 'show advanced options', 1;  
GO  
RECONFIGURE WITH OVERRIDE;  
GO  
EXEC sp_configure 'max degree of parallelism', 8;  
GO  
RECONFIGURE WITH OVERRIDE;  
GO  
Run Code Online (Sandbox Code Playgroud)

sql sql-server azure-sql-database

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

收到错误:void' 无法分配给 React js 中的类型 'FC<IPickWinnerProps>'

当我运行我的网站时,我在 React js 中收到此错误

TypeScript error in /var/www/oxygen/allbadcards/client/src/Areas/Game/GamePlayBlack.tsx(29,14):
Type '({ onPickWinner, canPick, timeToPick, hasWinner, revealMode }: PropsWithChildren<IPickWinnerProps>) => void' is not assignable to type 'FC<IPickWinnerProps>'.
  Type 'void' is not assignable to type 'ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)> | null'.  TS2322
Run Code Online (Sandbox Code Playgroud)

在这里,我已经上传了我的整个代码,任何人都可以帮助我为什么我会收到此错误吗?

GamePlayBlack.tsx

export interface IPickWinnerProps
{
    children?: undefined;
    canPick: boolean;
    timeToPick: boolean;
    revealMode: boolean;
    hasWinner: boolean;
} …
Run Code Online (Sandbox Code Playgroud)

reactjs

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

在图表 js 工具提示字体大小中不起作用

我想在图表js中制作大字体的工具提示,但不幸的是它对我不起作用,在这里我添加了我的代码,任何人都可以检查我的代码,并帮助我解决这个问题吗?

options: {
  plugins: {
    legend: {
      display: true,
      position: 'bottom',
      labels: {
        font: {
          size: 30
        }
      }
    },
    tooltips: {
      font: {
        size: 30
      }
    }
  },

}
Run Code Online (Sandbox Code Playgroud)

charts chart.js

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

获取错误:用户类型的对象在 django python 中不是 JSON 可序列化的

我是 django python 的新手,当我试图从 3 个表中获取数据时,出现错误Object of type User is not JSON serializable,谁能帮助我为什么会出现此错误?在这里我添加了我的views.pymodels.py文件

视图.py

# views.py
from tokenize import Token

from django.contrib.auth import authenticate
from rest_framework import status
from rest_framework.exceptions import ValidationError
from rest_framework.status import HTTP_400_BAD_REQUEST, HTTP_200_OK
from rest_framework.views import APIView
from rest_framework.response import Response
from django.conf import settings
from rest_framework.permissions import AllowAny
from django.contrib.auth.models import User
from django.contrib.auth.hashers import make_password
from django.core.exceptions import ValidationError
from django.core.validators import validate_email
from . import utils
import …
Run Code Online (Sandbox Code Playgroud)

python django django-models django-views django-rest-framework

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