小编AMe*_*dis的帖子

@ types/googlemaps/index.d.ts'不是模块

我想在我的Angular项目中使用Google Maps API,因此我使用这两个命令来安装npm包:

npm install @agm/core --save-dev
npm install @types/googlemaps --save-dev
Run Code Online (Sandbox Code Playgroud)

我将此行添加到我的组件中:

import {} from "@types/googlemaps";
Run Code Online (Sandbox Code Playgroud)

但是我在VS Code中看到了这两个错误:

[ts] File 'h:/Angular Projects/Breakfast/client/breakfast/node_modules/@types/googlemaps/index.d.ts' is not a module.
[ts] Cannot import type declaration files. Consider importing 'googlemaps' instead of '@types/googlemaps'.
Run Code Online (Sandbox Code Playgroud)

我添加了这些行

"types": ["googlemaps"]
"moduleResolution": "node"
Run Code Online (Sandbox Code Playgroud)

到tsconfig.json和tsconfig.spec.json,但仍然没有运气.在Chrome开发工具上,我看到以下错误:

Error: Uncaught (in promise): TypeError: Cannot read property 'Autocomplete' of undefined
TypeError: Cannot read property 'Autocomplete' of undefined
Run Code Online (Sandbox Code Playgroud)

角度版本6打字稿版本2.9.2

我也尝试过Angular 5.

typescript angular-cli angular angular-cli-v6

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

使用打字稿反应 useTable 钩子

所以我有一个带有 useTable 的 JavaScript 类。在Java脚本中它的使用如下

import {useTable, useFilters,useAsyncDebounce,useSortBy,usePagination,} from "react-table";

const {getTableProps,getTableBodyProps, headerGroups, page,prepareRow,state,visibleColumns, nextPage,pageOptions,pageCount,previousPage,canPreviousPage,canNextPage,setPageSize,gotoPage
      } = useTable({columns,data,defaultColumn,filterTypes,initialState: { pageSize: 10, pageIndex: 0 }
       },useFilters, useSortBy,usePagination);
Run Code Online (Sandbox Code Playgroud)

我正在将我的 javascript 项目转换为 typescript。

在打字稿中,该useTable行给出了错误。

例子 :Property 'page' does not exist on type 'TableInstance<object>'.ts(2339)

在此输入图像描述

initialState属性给出了我的以下错误

Type '{ pageSize: number; pageIndex: number; }' is not assignable to type 'Partial<TableState<object>>'.
  Object literal may only specify known properties, and 'pageSize' does not exist in type 'Partial<TableState<object>>'.ts(2322)
index.d.ts(172, 5): The expected type comes …
Run Code Online (Sandbox Code Playgroud)

javascript typescript reactjs react-table react-table-v7

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

在带有 typescript 的 Material ui 中使用 makeStyles

我正在尝试将 JavaScript 模板转换为 Typescript。所以我有这个 AccordionStyle.ts 如下

import {
  primaryColor,
  grayColor
} from "../../material-dashboard-pro-react";

const accordionStyle = (theme?:any) => ({
  root: {
    flexGrow: 1,
    marginBottom: "20px"
  },
  expansionPanel: {
    boxShadow: "none",
    "&:before": {
      display: "none !important"
    }
  },
  expansionPanelExpanded: {
    margin: "0 !important"
  },
  expansionPanelSummary: {
    minHeight: "auto !important",
    backgroundColor: "transparent",
    borderBottom: "1px solid " + grayColor[5],
    padding: "25px 10px 5px 0px",
    borderTopLeftRadius: "3px",
    borderTopRightRadius: "3px",
    color: grayColor[2],
    "&:hover": {
      color: primaryColor[0]
    }
  },
  expansionPanelSummaryExpaned: {
    color: primaryColor[0],
    "& $expansionPanelSummaryExpandIcon": { …
Run Code Online (Sandbox Code Playgroud)

javascript typescript reactjs material-ui

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

在经过一定数量的 epoch 之后,GAN 中的假图像创建变得最糟糕

我正在尝试创建 GAN 模型。这是我的 discriminator.py

import torch.nn as nn
class D(nn.Module):
    feature_maps = 64
    kernel_size = 4
    stride = 2
    padding = 1
    bias = False
    inplace = True

    def __init__(self):
        super(D, self).__init__()
        self.main = nn.Sequential(
            nn.Conv2d(4, self.feature_maps, self.kernel_size, self.stride, self.padding, bias=self.bias),
            nn.LeakyReLU(0.2, inplace=self.inplace),
            nn.Conv2d(self.feature_maps, self.feature_maps * 2, self.kernel_size, self.stride, self.padding,
                      bias=self.bias),
            nn.BatchNorm2d(self.feature_maps * 2), nn.LeakyReLU(0.2, inplace=self.inplace),
            nn.Conv2d(self.feature_maps * 2, self.feature_maps * (2 * 2), self.kernel_size, self.stride, self.padding,
                      bias=self.bias),
            nn.BatchNorm2d(self.feature_maps * (2 * 2)), nn.LeakyReLU(0.2, inplace=self.inplace),
            nn.Conv2d(self.feature_maps * (2 * 2), …
Run Code Online (Sandbox Code Playgroud)

python artificial-intelligence conv-neural-network pytorch generative-adversarial-network

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

访问 kubernetes 仪表板时出现错误尝试访问服务:'dial tcp 10.44.0.2:8443: connect: connection denied'

我艰难地使用了 kubernetes 并成功地使用 kubernetes 1.18.6 部署了一个集群

我使用了 vmware 和 kubernetes 1.18.6。我部署了 metric-server 和 kubernets 仪表板

我用这个命令 --> kubectl proxy --address='0.0.0.0' --port=8001 --accept-hosts='^*$' 来启动 kuberenetes 仪表板

然后我使用下面的 url 从我的主节点访问 kubernes 仪表板

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
Run Code Online (Sandbox Code Playgroud)

但是我的浏览器出现以下错误

Error trying to reach service: 'dial tcp 10.44.0.2:8443: connect: connection refused'
Run Code Online (Sandbox Code Playgroud)

但是我可以使用 url https://10.44.0.2:8443/在我的工作节点上访问 kubernetes 仪表板而没有任何问题

我错过了什么?

为什么我无法以正常方式访问 kubernetes 仪表板?

我使用 kubeadm 工具创建了另一个集群,我可以在集群外访问 kubernetes 仪表板。

我已经配置了 weave 和 coredns,我没有看到它们有任何错误。我做了一个烟雾测试,一切正常。我什至部署了 wordpress,它也能正常工作。

我所有的配置都在https://github.com/godomainz/kubernetes-the-hard-way.git feature/Feature-1.18.6分支中

来宾操作系统:Ubuntu 18.04 使用的
集群环境:VMWare 工作站
主机 PC:Windowd 10 Pro(i7 处理器,64GB 内存)
每个 VM …

cluster-computing kubernetes kubernetes-dashboard kubernetes-networking kubernetes-metrics

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

实现多用户的Docker隔离

我被要求为多个用户配置带有 docker 的 ubuntu 18.04 服务器。

目的:我们有多个测试人员编写测试用例。但是我们的笔记本电脑的速度不够快,无法在 docker 环境中构建项目和运行 tescase。我们已经有一个 jenkins 服务器。但是我们需要在推送到 git 之前构建/测试我们的代码。

我得到了一个高端的 ubuntu 18.04 服务器。我必须配置服务器,让我们所有的测试人员都可以在隔离的环境中运行/调试我们的测试用例。

当测试人员将更改推送到远程服务器时,项目应该在隔离的环境中构建和运行。多个用户可以在同一个项目上工作,但一个测试人员的构建不能影响另一个。

我已经安装了 Docker 并尝试仅更改 docker-compose.yml 并添加不同的网络(当然使用多个帐户)。但这是非常痛苦的。

我需要有多个 selenoid 服务器(针对不同的用户),使用 docker 的不同诱惑报告,需要能够使用我们的 docker-compose 文件构建和运行测试,并且需要能够在不同端口上运行实际项目以便我们可以通过编写测试用例的系统。

是否可以在不更改项目 docker-compose.yml 的情况下配置环境?我应该采取什么方法?

docker kubernetes docker-compose

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

无法使用 NodePort 服务从浏览器访问 Microk8s 服务

我根据此处的步骤在我的 ubuntu 计算机上安装了 microk8s https://ubuntu.com/kubernetes/install#single-node

然后我按照 kubernetes 官方教程创建并公开了这样的部署

microk8s.kubectl create deployment kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1

microk8s.kubectl expose deployment/kubernetes-bootcamp --type=NodePort --port 8083
Run Code Online (Sandbox Code Playgroud)

这是我的kubectl get services输出

akila@ubuntu:~$ microk8s.kubectl get services
NAME                  TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
kubernetes            ClusterIP   10.152.183.1    <none>        443/TCP          25h
kubernetes-bootcamp   NodePort    10.152.183.11   <none>        8083:31695/TCP   17s
Run Code Online (Sandbox Code Playgroud)

这是我的kubectl get pods输出

akila@ubuntu:~$ microk8s.kubectl get pods
NAME                                   READY   STATUS    RESTARTS   AGE
kubernetes-bootcamp-6f6656d949-rllgt   1/1     Running   0          51m
Run Code Online (Sandbox Code Playgroud)

但我无法使用http://localhost:8083或使用从浏览器访问该服务http://10.152.183.11:31695

当我尝试 http://localhost:31695 时,我收到 ERR_CONNECTION_REFUSED。

如何从浏览器访问此“kubernetes-bootcamp”服务?我错过了什么吗?

kubernetes kubernetes-ingress kubernetes-pod microk8s

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

此表达式不可调用。并非所有类型为 'string | 的成分| ((searchTerm: string) =&gt; Promise&lt;void&gt;) | []' 是可调用的

我有这样的自定义useResults钩子

import { useEffect, useState } from 'react';
import yelp from '../api/yelp';

export default () => {
  const [results, setResults] = useState([]);
  const [errorMessage, setErrorMessage] = useState('');

  const searchApi = async (searchTerm:string) => {
    console.log('Hi there!');
    try {
      const response = await yelp.get('/search', {
        params: {
          limit: 50,
          term: searchTerm,
          location: 'san jose'
        }
      });
      setResults(response.data.businesses);
    } catch (err) {
      setErrorMessage('Something went wrong');
    }
  };

  useEffect(() => {
    searchApi('pasta');
  }, []);

  return [searchApi, results, errorMessage];
};
Run Code Online (Sandbox Code Playgroud)

在我的搜索屏幕中,我导入我的自定义钩子并进行这样的解构

const …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs react-native

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

使用 Cypress.IO 将 HTML 转换为 PDF

我想知道是否可以将使用访问的页面转换cy.visit(url)为 pdf ?Chrome api有Page.printToPDF https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF 是否可以通过Cypress.IO访问chrome api并将当前页面打印到pdf文件?我搜索互联网但没有找到合适的解决方案

cypress

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