小编Ahm*_*ssy的帖子

mapDispatchToProps无法正常工作。道具为空(错误:redux操作不是函数)

我收到此错误:this.props.postBooks不是函数。

我有一个动作-postBooks-我正尝试通过道具发送。

这是我的组件:

"use strict"

import React from 'react'
import {Well,Panel,FormControl,FormGroup,ControlLabel,Button} from 'react-bootstrap'
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import {postBooks} from '../../actions/booksActions'
import {findDOMNode} from 'react-dom'

export class BooksForm extends React.Component{

    handleSubmit(){
        const book = [{
            title: findDOMNode(this.refs.title).value,
            description: findDOMNode(this.refs.description).value,
            price: findDOMNode(this.refs.price).value
        }]
        this.props.postBooks(book)
    }
    render(){

        return(
            <Well>
                <Panel>
                    <FormGroup    controlId='title'>
                        <ControlLabel> Title </ControlLabel>
                        <FormControl    
                            type='text'
                            placeholder='Enter Title'
                            ref='title' />
                    </FormGroup>

                    <FormGroup    controlId='description'>
                        <ControlLabel> Enter Description </ControlLabel>
                        <FormControl    
                            type='text'
                            placeholder='Enter Description'
                            ref='description' />
                    </FormGroup>

                    <FormGroup    controlId='price'>
                        <ControlLabel> …
Run Code Online (Sandbox Code Playgroud)

reactjs redux react-redux

4
推荐指数
3
解决办法
4819
查看次数

VS Code 将所有 html 文件默认为 Django 模板并以错误的方式对其进行注释(如果我按 ctrl + /)

VS Code 将所有 html 文件默认为 Django 模板并以错误的方式对其进行注释(如果我按 ctrl + /)

即它通过添加 {% comment %} & {% endcomment %} 而不是正确的 html 注释来注释普通的 html 文件 <!-- -->

html visual-studio-code

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

Spring Security antMatchers不会应用于POST请求,并且只能与GET一起使用

我正在使用Spring安全性库来保护我的应用程序中的REST api,现在尝试尝试允许(临时)访问所有URL,但是通过以下配置,我发现仅允许GET请求,而不允许POST请求(在这里我得到403)禁止响应),我知道下面的第一个antmatcher应该同时允许GET和POST,但实际上2个antMatchers不允许POST

有人可以告诉我我在这里缺少什么吗?

protected void configure(HttpSecurity http) throws Exception {
    http
        .authorizeRequests()
// first I have tried only this antMatcher
            .antMatchers("/**").permitAll()
// But then it didn't allow POST even when only using the line below
            .antMatchers(HttpMethod.POST, "/**").permitAll()
}
Run Code Online (Sandbox Code Playgroud)

java spring spring-security

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

调用从Angular 6下载pdf的Spring启动api给出错误无法解析响应

我有一个创建pdf报告并下载它的spring boot API,如果我直接在浏览器中调用API,则直接创建和下载pdf,但是当我从Angular 6调用GET API时,我收到以下错误:

Spring启动(java)代码:

@RequestMapping(value = "/app_report/en", method = RequestMethod.GET)
@ResponseBody
public void getEnRpt(HttpServletResponse response, @RequestParam("appNum") String appNum) throws JRException, IOException, SQLException {

    JasperReport jasperReport = JasperCompileManager.compileReport("./src/main/resources/jasperReports/App_created_en.jrxml");

    Connection connection = dataSource.getConnection();

    Map<String, Object> params = new HashMap<>();
    params.put("P_APP_NO", appNum);
    JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, connection);

    response.setContentType("application/x-pdf");
    response.setHeader("Content-disposition", "inline; filename=App_report_en.pdf");

    final OutputStream outStream = response.getOutputStream();
    JasperExportManager.exportReportToPdfStream(jasperPrint, outStream);
}
Run Code Online (Sandbox Code Playgroud)

调用API的Angular代码:(我试过多种方式,这里显示了两个):

this.http.get(this.api_url + reportUrl, {
  responseType: 'blob'
}, ).subscribe((response: File) => {
  console.log('report is downloaded');
});

this.http.get(this.api_url + reportUrl).subscribe(
  (response) => …
Run Code Online (Sandbox Code Playgroud)

javascript typescript angular angular-httpclient

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

无法克隆git repo并出现错误ssh_askpass:exec(/ usr / bin / ssh-askpass):没有此类文件或目录主机密钥验证失败

我试图使用vs代码git plugin从gitlab克隆git repo,但我一直收到此错误:

ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory Host key verification failed
Run Code Online (Sandbox Code Playgroud)

在此之前,我确保将ssh密钥添加到Gitlab中,并且已授权该密钥可以访问存储库,如何解决此问题?

git ssh

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

如何将角材料表单包装到组件中并将它们作为 formControl 元素公开给 FormGroup

我正在尝试将一个组件(例如称为custom-input)封装为基于 Angular 材质组件的 formControl 元素,以包含以下内容:

<mat-form-field >
  <input
    matInput
    [formControl]="inputField"
    formControlName="{{ name }}"
    name="{{ name }}"
    maxlength="{{ maxlength }}"
    placeholder="{{ name | translate }}"
    required
  />
  <mat-error *ngIf="inputField.errors">{{
    this.validationService.getErrorMsg(inputField.errors)
  }}</mat-error>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)

现在这个组件正在使用所需的功能,但不能像普通输入或 matInput一样使用 formControlName 属性绑定到 formGroup(例如下面的例子,它直接绑定到 formGroup 没有问题)

<input
  matInput
  formControlName="inputField123"
  placeholder="{{ 'testInput' | translate }}"
  required
/>
Run Code Online (Sandbox Code Playgroud)

问题是如何让上面的组合组件绑定为formGroup中的formControl元素?我应该实现或公开什么来提供此功能?

我应该使用 ControlValueAccessor 还是有更好的方法用于材质输入组件?

javascript typescript angular2-forms angular angular-reactive-forms

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

如果带有&的elif语句给出了意想不到的输出

我正在尝试学习python并在尝试在网站上解决此测验时,我得到一个奇怪的错误,即第二个参数的断言失败,而if ifif语句是正确的并且应该给出正确的输出(但它给出错误的意外输出)

错误是:

"C:\Program Files\Python36\python.exe" C:/Users/.../PycharmProjects/pythonSnakegame/snakeGame.py
Fizz Buzz
Traceback (most recent call last):
Fizz Buzz
  File "C:/Users/..../PycharmProjects/pythonSnakegame/snakeGame.py", line 28, in <module>
    assert checkio(6) == "Fizz", "6 is divisible by 3"
AssertionError: 6 is divisible by 3

Process finished with exit code 1

def checkio(number):
    # Your code here
    # It's main function. Don't remove this function
    # It's using for auto-testing and must return a result for check.
    if number % 3 == 0 & number % 5 == 0: …
Run Code Online (Sandbox Code Playgroud)

python if-statement fizzbuzz

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