问题列表 - 第284720页

如何修复:this.setDynamic 不是函数

我的 babel 配置有问题,不知道是什么问题。

我看到的错误:

 ERROR  Failed to compile with 1 errors                                                                                          friendly-errors 21:27:50


 ERROR  in ./.nuxt/client.js                                                                                                     friendly-errors 21:27:50

Module build failed (from ./node_modules/@nuxt/webpack/node_modules/babel-loader/lib/index.js):                                  friendly-errors 21:27:50
TypeError: this.setDynamic is not a function
Run Code Online (Sandbox Code Playgroud)

我的 .babelrc 看起来像这样:

{
  "presets": [
    [
      "vue-app",
      {
        "useBuiltIns": true
      }
    ],
    "flow"
  ],
  "plugins": ["@babel/plugin-proposal-decorators", "@babel/plugin-proposal-class-properties"],
  "env": {
    "test": {
      "plugins": ["babel-jest-assertions", "transform-runtime"]
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

包锁,安装的插件:

"@babel/core": "^7.4.5",
    "@babel/preset-env": "^7.4.5",
    "@nuxtjs/google-analytics": "^2.2.0",
    "acorn": "^6.1.1",
    "axios": "^0.18.1",
    "babel-jest-assertions": "^0.1.0",
    "babel-plugin-transform-decorators-legacy": "^1.3.5",
    "babel-preset-flow": "^6.23.0",
Run Code Online (Sandbox Code Playgroud)

需要更改什么才能使此配置正常工作?已经访问了各种 stackoverflow 答案,但尚未找到有效的解决方案。

评论后更新配置: …

webpack vue.js babeljs babel-loader nuxt.js

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

Is it OK to make a REST API request from within a Redux reducer?

I have a React component named ItemList which loads a list of items from an API server and then renders them as a list of Item components.

Each Item has a delete button. When the button is clicked, I want to send a request to the API server to delete the item, then re-render the ItemList.

One way I can think of to make that work is to move both API queries into reducers, and then dispatch actions whenever …

reactjs react-redux

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

Using OrdinalEncoder to transform categorical values

我有一个包含很多列的数据集

No  Name  Sex  Blood  Grade  Height  Study
1   Tom   M    O      56     160     Math
2   Harry M    A      76     192     Math
3   John  M    A      45     178     English
4   Nancy F    B      78     157     Biology
5   Mike  M    O      79     167     Math
6   Kate  F    AB     66     156     English
7   Mary  F    O      99     166     Science
Run Code Online (Sandbox Code Playgroud)

我想把它改成那样

No  Name  Sex  Blood  Grade  Height  Study
1   Tom   0    0      56     160     0
2   Harry 0    1      76     192     0
3 …
Run Code Online (Sandbox Code Playgroud)

python scikit-learn

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

Swashbuckle 和 Swagger 库无法识别“信息”类

我是否缺少包或参考,因为我的AddSwaggerGen方法无法编译。我的代码:

我加了 using Swashbuckle.AspNetCore.Swagger;

但是这个代码

  services.AddSwaggerGen(c =>
   {
     c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });                 
     c.EnableAnnotations();    
   });
Run Code Online (Sandbox Code Playgroud)

不会编译:

错误 CS0246 找不到类型或命名空间名称“信息”(您是否缺少 using 指令或程序集引用?)这是 csproj

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <DebugType>full</DebugType>
    <DebugSymbols>true</DebugSymbols>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <DebugType>full</DebugType>
    <DebugSymbols>true</DebugSymbols>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="IdentityModel" Version="3.10.6" />
    <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.0.0-rc2" />
    <PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.0.0-rc2" />
    <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.0.0-rc2" />
    <PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.0.0-rc2" />
  </ItemGroup>
Run Code Online (Sandbox Code Playgroud)

c# swagger asp.net-core

8
推荐指数
2
解决办法
4873
查看次数

如何在 Python 中为 Hackerrank 解决闰年函数?

我一生都无法在 Hackerrank 上解决这个挑战。我得到的最接近的是 4/6 次传球。规则:在公历中,必须考虑三个标准来确定闰年:

The year can be evenly divided by 4, is a leap year, unless:
    The year can be evenly divided by 100, it is NOT a leap year, unless:
        The year is also evenly divisible by 400. Then it is a leap year.
Run Code Online (Sandbox Code Playgroud)

代码:

The year can be evenly divided by 4, is a leap year, unless:
    The year can be evenly divided by 100, it is NOT a leap year, unless:
        The year is also …
Run Code Online (Sandbox Code Playgroud)

python

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

如何在 2 个不同的 cloudformation 模板中创建 S3 和触发的 lambda

是否可以在单独的 CloudFormation 模板中创建 S3 存储桶和触发的 Lambda。我希望将长时间运行的资源堆栈与 Lambda 等经常更新的资源堆栈分开

当尝试单独创建 Lambda 时,它表示 lambda 事件中定义的存储桶应该在同一模板中定义,并且不能被引用。

S3 事件必须引用同一模板中的 S3 存储桶。

GetFileMetadata:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: !Sub '${targetenv}-lambdaname'
      CodeUri: target-file-0.0.1-SNAPSHOT.jar
      Handler: LambdaFunctionHandler::handleRequest
      Runtime: java8
      Timeout: 30
      MemorySize: 512
      Environment:
        Variables:
          STAGE: !Sub '${targetenv}'
          
      Events:
        S3Event:
          Type: S3
          Properties:
            Bucket:
              Ref: MyS3Bucket
            Events:
              - 's3:ObjectCreated:*'
  
  MyS3Bucket:
      Type: 'AWS::S3::Bucket'
      DependsOn: BucketPermission
      Properties:
          BucketName: !Sub 'bucketname-${targetenv}'
Run Code Online (Sandbox Code Playgroud)

amazon-s3 amazon-web-services aws-cloudformation aws-lambda aws-sam

7
推荐指数
2
解决办法
5374
查看次数

PyInstaller exe 在 Tkinter 脚本上返回错误

我正在尝试通过 Pyinstaller 打包使用标准 python 库和 Tkinter GUI 构建的简单小程序以进行分发。PyInstaller 编译(正确的术语?)它很好,但是当我打开 exe 时,我得到以下信息:

Traceback (most recent call last):
  File "site-packages/PyInstaller/loader/rthooks/pyi_rth__tkinter.py", line 28, in <module>
FileNotFoundError: Tcl data directory "/var/folders/sj/r0yyz8393ld2xrd_wf65bwxr0000gn/T/_MEIDeFnFy/tcl" not found.
[67821] Failed to execute script pyi_rth__tkinter
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]
Run Code Online (Sandbox Code Playgroud)

我试过调整我的编译设置,例如添加--hidden-import tkinter无济于事。

这是脚本:

import math
import tkinter as tk
from tkinter import simpledialog as sd

grades = []

def convert(grades):
    #long function here

def get_num_classes():
    while True:
        try:
            global num_classes …
Run Code Online (Sandbox Code Playgroud)

python tkinter pyinstaller

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

使用 WebWorker 从导入其他类的文件中导入类会导致 Angular 8 编译失败

我正在使用 Angular v8。我有一个名为的文件model.ts,如下所示。

import {map} from 'rxjs/operators';

export class Person {
 constructor() { }
}
Run Code Online (Sandbox Code Playgroud)

然后我有一个名为的 WebWorker 文件test.worker.ts,如下所示。

/// <reference lib="webworker" />
import {Person} from './bo/model';

addEventListener('message', ({ data }) => {
  const response = `worker response to ${data}`;
  postMessage(response);
});
Run Code Online (Sandbox Code Playgroud)

当我输入时,ng compile我得到以下内容ERROR

./src/app/test.worker.ts (./node_modules/worker-plugin/dist/loader.js!./src/app/test.worker.ts) 中的错误
模块构建失败(来自 ./node_modules/worker-plugin/dist/loader.js):
错误:node_modules/rxjs/internal/types.d.ts(45,13):错误 TS2339:类型“SymbolConstructor”上不存在属性“observable”。

    在 AngularCompilerPlugin._update (/Users/jwayne/my-app/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:767:31)
    在 processTicksAndRejections (internal/process/task_queues.js:89:5)
    在异步 AngularCompilerPlugin._make (/Users/jwayne/my-app/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:658:13)

如果我注释掉import {map} from 'rxjs/operators',那么我可以编译。导入导入其他库的库是否有限制?

有趣的是,如果我执行此导入,import {HttpClient} from '@angular/common/http';则会出现如下不同的错误。

./src/app/test.worker.ts …

javascript web-worker typescript webpack angular

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

Python -m http.server 443 - 使用 SSL?

是否可以使用 SSL 证书创建临时 Python3 HTTP 服务器?例如:

$ python3 -m http.server 443 --certificate /path/to/cert
Run Code Online (Sandbox Code Playgroud)

python ssl http python-3.x server

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

在 SwiftUI 中获取 ScrollView 的当前位置?

我看到了 position 属性,但我认为它只是用来设置 x 和 y 的,但我不知道如何识别当前位置。

或者完全如何使用像 onHover 这样的事件收入属性?

swift swiftui

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