小编Has*_*tin的帖子

Reactjs中的Typescript如何制作动态Props类型?

我想创建一个通用的 Table 组件。


type HeadCell<DataType> = {
  id: keyof DataType;
  label: string;
};

type TableProps<DataType> = {
  heads: HeadCell<DataType>[];
  rows: Array<DataType>;
};

const Table = ({ heads, rows }: TableProps) => {
  const ColumnsKeys = heads.map(
    (item: { [key: string]: any }) => item.id
  );

  return (
    <table>
      <tr>
        {heads.map((head: string, headKey: number) => {
          return (
            <th key={headKey}>{head.label}</th>
          );
        })}
      </tr>

      {rows.map((row, rowKey) => {
        return (
          <tr key={rowKey}>
            {ColumnsKeys.map((column: string, columnKey: number) => {
              return (
                <td key={columnKey}>{row[column]}</td> …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs typescript-generics react-props react-typescript

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

如何使用 docker-compose 来构建 Dockerfile?

我有这样的结构:

在此输入图像描述

在我的 Makefile 中,我构建了 dockerfile:

sudo docker build --build-arg PHP_VERSION=7.4 -t kaiza/image-php74 - < dockerfile/Dockerfile.php
Run Code Online (Sandbox Code Playgroud)

kaiza /image-php74在本地创建得很好,如果我这样做docker images,我会得到:

在此输入图像描述

然后,在我的 docker-compose.php74.yml 中:

version: '2.4'

services:
  php7.4:
    image: "kaiza/image-php74"
    container_name: "kz-php74"
    hostname: "kz-php74"
    user: 1000:1000
...
Run Code Online (Sandbox Code Playgroud)

但是,当我运行它时

docker-compose -f docker-compose/php/docker-compose.php74.yml up --build -d
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

“kaiza/image-php74 的拉取访问被拒绝,存储库不存在或可能需要‘docker 登录’:被拒绝:请求的资源访问被拒绝”

任何人都知道如何在不通过注册表解决方案的情况下解决这个问题(以将所有内容保留在本地)?

谢谢。

docker dockerfile docker-compose devops

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

Typescript papaparse 没有重载与此调用匹配

我在打字稿中使用Papaparse lib。

import Papa from 'papaparse';

Papa.parse(filePath, {
  download: true, 
  header: true,
  dynamicTyping: true,
  skipEmptyLines: true,
};
Run Code Online (Sandbox Code Playgroud)

filepath类型是string

我在 filePath 上收到错误:

No overload matches this call. The last overload generated the following error. The 'string' type argument is not assignable to the 'unique symbol' type parameter.
Run Code Online (Sandbox Code Playgroud)

@types/papaparse中,有


/**
 * Parse local files
 * @param file a File object obtained from the DOM.
 * @param config a config object which contains a callback.
 * @returns Doesn't …
Run Code Online (Sandbox Code Playgroud)

javascript node.js typescript reactjs papaparse

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