小编meh*_*sum的帖子

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万
查看次数

Reactjs 在刷新时保持 Material Ui Tab 被选中

嗨,我正在使用 React Material UI 选项卡,我注意到刷新时网站没有选择选项卡。我怎样才能防止这种情况发生?这是一个代码类型的材料 ui 选项卡

class SimpleTabs extends React.Component {
  state = {
    value: 0,
  }

  handleChange = (event, value) => {
    this.setState({ value })
  }

  render() {
    const { classes } = this.props
    const { value } = this.state

    return (
      <div className={classes.root}>
        <AppBar position="static">
          <Tabs value={value} onChange={this.handleChange}>
            <Tab label="Item One" />
            <Tab label="Item Two" />
            <Tab label="Item Three" />
          </Tabs>
        </AppBar>
        {value === 0 && <TabContainer>Item One</TabContainer>}
        {value === 1 && <TabContainer>Item Two</TabContainer>}
        {value === 2 …
Run Code Online (Sandbox Code Playgroud)

tabs reactjs material-ui

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

如何使用 WinPTY 运行 npm 脚本?

在 Windows 上的 Git bash 中遇到了python 冻结的已知问题。stackoverflow 上的许多答案都建议使用WinPTY

当我使用时,它工作正常:

winpty python foo.py

但是我将 python 程序作为 npm 脚本的一部分运行。我的 package.json 有这个:

"scripts": {
  "start": "python foo.py && something else"
} 
Run Code Online (Sandbox Code Playgroud)

所以我想我也需要用 WinPTY 运行 npm 脚本:

winpty npm start

但这是行不通的。我在不同的环境中收到了不同的错误消息。

  1. 我在安装了最新的 git 和 npm 的工作中遇到了“在 PATH 中找不到”,但在 PATH 中:

winpty:错误:无法启动“npm”:在路径中找不到

  1. 我在我的个人电脑上用一个稍微旧的 git 遇到了一个不同的错误:

错误 0x2 启动 npm start

任何想法为什么 npm 和 winpty 不能一起工作?

如果我在npm start没有 winpty 的情况下运行它可以正常工作。winpty node也有效。

windows npm git-bash

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

将映射数据传递到 Material-UI 模态

我正在尝试将值列表传递给按钮。单击按钮时,应该会出现具有特定映射值的模态,但在我的情况下,只有数组中的最后一个值(3)出现在所有模态中...我应该如何修复它?

  state = {
    open: false,
    stationData : [
      { id:1, number:'1' },
      { id:2, number:'2' },
      { id:3, number:'3' }
    ],
  };

  handleOpen = () => {
    this.setState({ open: true });
  };

  handleClose = () => {
    this.setState({ open: false });
  };

  render() {
    const {stationData} = this.state;
    {stationData.map((station,index) => (
        <div key={index}>
            <Button variant="contained" color="primary" style={styles.button} onClick={this.handleOpen}>
                {station.number}
            </Button>
            <Modal 
                open={this.state.open} 
                onClose={this.handleClose} 
                aria-labelledby={index} 
                aria-describedby={index}
            >
                <div style={styles.modal}>
                    {station.number}
                </div>
            </Modal>
        </div>
    ))}
  }
Run Code Online (Sandbox Code Playgroud)

查看此代码沙箱

reactjs material-ui

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

“无效的内容实体类型!” 发布到 Linkedin v2/shares 时

遵循此文档:https : //docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/rich-media-shares上传图像以在 LinkedIn 中的组织共享中引用。

使用Assets API成功上传图片。URN 采用这种格式 -urn:li:digitalmediaAsset:XXX

使用资产 ID 从 digitalmediaAsset URN检索资产信息显示以下状态:

{
    "serviceRelationships": [
        {
            "identifier": "urn:li:userGeneratedContent",
            "relationshipType": "OWNER"
        }
    ],
    "recipes": [
        {
            "recipe": "urn:li:digitalmediaRecipe:feedshare-image",
            "status": "AVAILABLE"
        }
    ],
    "mediaTypeFamily": "STILLIMAGE",
    "created": 1579015000150,
    "lastModified": 1579015039823,
    "id": "XXX",
    "status": "ALLOWED"
}
Run Code Online (Sandbox Code Playgroud)

但是当我使用 Assets URN编写共享时-

POST https://api.linkedin.com/v2/shares

{
    "content": {
        "contentEntities": [
            {
                "entity": "urn:li:digitalmediaAsset:XXX"
            }
        ],
        "description": "content description",
        "title": "Test Share with Content"
    },
    "distribution": {
        "linkedInDistributionTarget": …
Run Code Online (Sandbox Code Playgroud)

linkedin linkedin-api

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

redux-persist:undefined不是对象(正在评估store.getState)

这是我第一次使用Redux和Redux Persist。当我尝试运行我的应用程序时出现此错误(在index.js第20行中):

TypeError:未定义不是对象(正在评估“ store.getState”)

index.js:

import React from 'react';
import { AppRegistry } from 'react-native';
import App from './App';
import { name as appName } from './app.json';
import { Provider } from 'react-redux';
import {persistor, store}from './store/configureStore';
import { PersistGate } from 'redux-persist/integration/react';

const RNRedux = () => (
    <Provider store={store}>
        <PersistGate loading={null} persistor={persistor}>
            <App/>
        </PersistGate>
    </Provider>
)

AppRegistry.registerComponent(appName, () => RNRedux);
Run Code Online (Sandbox Code Playgroud)

App.js:

import {createStackNavigator, createAppContainer} from 'react-navigation';
import Register from './components/Register';
import Home from './components/Home';
import Login from './components/Login'; …
Run Code Online (Sandbox Code Playgroud)

react-native redux redux-persist

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