小编Gin*_*ead的帖子

React AntDesign 将上传的图像添加到 FormData

我想使用AntDesign 库中的图像上传器。这是一个快照

import { Upload, Icon, Modal } from 'antd'

class PicturesWall extends React.Component {
  state = {
    previewVisible: false,
    previewImage: '',
    fileList: [],
  }

  handleCancel = () => this.setState({ previewVisible: false })

  handlePreview = file => {
    this.setState({
      previewImage: file.url || file.thumbUrl,
      previewVisible: true,
    })
  }

  handleChange = ({ fileList }) => this.setState({ fileList })

  render() {
    const { previewVisible, previewImage, fileList } = this.state
    const uploadButton = (
      <div>
        <Icon type="plus" />
        <div className="ant-upload-text">Upload</div>
      </div> …
Run Code Online (Sandbox Code Playgroud)

reactjs antd

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

在 Heroku 上发送 Django 电子邮件

这是我在 settings.py 文件中的属性:

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'infobot9@gmail.com'
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
EMAIL_PORT = 587
Run Code Online (Sandbox Code Playgroud)

这是我的发送电子邮件方法:

from django.core.mail import send_mail 


def sendConfirmEmail(email, instance, code):
    mail_subject = 'Confirmation code {}'.format(code)
    message = render_to_string("msg.html", {
       'user': instance,
       'code': code

    })
    to_email = email
    send_mail(mail_subject, message, 'infobot9@gmail.com', [to_email], 
              fail_silently=False)
Run Code Online (Sandbox Code Playgroud)

我的 Django 电子邮件发送方法在我的本地主机上运行良好。将其部署到 Heroku 后,我在 Gmail 设置中允许从未知设备登录。Gmail 不允许服务器登录我的帐户并向我发送消息:

恶意登录尝试被阻止

?infobot9@gmail.com

有人试图使用为他们设置的密码登录您的帐户。如果不是您本人,我们建议您尽快更改密码。

?

未知设备

?

4 月 4 日 11:39

?

靠近这个地方:都柏林,爱尔兰

176.34.163.6(IP地址)

我应该在我的settings.py文件中设置额外的参数还是需要更改我的 Gmail 帐户设置?

python email django heroku

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

使用 redux store 设置 React 组件的状态

如何将 redux 存储的某些值分配给我的组件本地状态?

我应该在我的 componentDidMount() 方法中使用 redux 操作从 API 获取数据。我对吗?通过 redux 获取数据后,我想使用 redux 存储中的数据设置组件的状态。我收到错误this.props.article 未定义。,但是 redux devtools 显示article对象存在。

我应该在哪里调用this.setState()方法???我尝试在componentWillRecieveProps () 或componentDidUpdate ()中调用它,但没有成功。请提供任何帮助。预先感谢您。

import React, { Component, Fragment } from 'react';
import { Typography,Spin } from 'antd';
import {connect} from 'react-redux';
import {getArticleDetails} from '../store/actions/articles';



class ArticleEdit extends Component {
    articleID = this.props.match.params.articleID; 
    state={

        str:'initial'
    }
    onChange = (str) => {
        console.log('Content change:', str);
        this.setState({ str1:str });

      };
    componentDidMount(){
        this.props.getArticleDetails(this.articleID);// GET data from api
        this.setState({str:this.props.article.title});// …
Run Code Online (Sandbox Code Playgroud)

reactjs redux react-redux

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

在svg中绘制半透​​明箭头

我有一个箭头 React 组件,它使用给定的代码在板上绘制一个箭头。问题是当我想绘制一个半透明箭头时,它看起来很难看,因为形状合并的区域变得更暗。

考虑到使箭头精确位于道具给出的坐标上很重要,我该如何修复它?

const Arrow = ({ from, to, customArrowColor }) => (
  <Fragment>
    <defs>
      <marker
        id="arrowhead"
        markerWidth="2"
        markerHeight="2.5"
        refX="1.25"
        refY="1.25"
        orient="auto"
      >
        <polygon
          points="0 0, 2 1.25, 0 2.5"
          style={{ fill: "rgba(28, 195, 42, 0.35)" }}
        />
      </marker>
    </defs>
    <line
      x1={from.x}
      y1={from.y}
      x2={to.x}
      y2={to.y}
      style={{
        stroke: "rgba(28, 195, 42, 0.35)",
      }}
      markerEnd="url(#arrowhead)"
    />
  </Fragment>
);
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

svg reactjs

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

标签 统计

reactjs ×3

antd ×1

django ×1

email ×1

heroku ×1

python ×1

react-redux ×1

redux ×1

svg ×1