monitor.getDropResult()返回null(我看它是console.log).它应该返回对象(拖动项)及其位置.为什么它返回null?
我使用DragSource,DropTarget对我的组件进行签名.但它仍然返回null
这是我的整个组件代码:
import React, { PropTypes } from 'react';
import { DragSource } from 'react-dnd';
import { getEmptyImage } from 'react-dnd-html5-backend';
import { StoneConstants, StoneTypes, ItemTypes } from 'constants/AppConstants';
import OkeyStoneBase from 'components/OkeyStoneBase/OkeyStoneBase';
import './_OkeyStone.scss';
function checkForDragAction(props) {
// TODO receive the action via prop
if (props.stoneType === StoneTypes.ON_WITHDRAW_MIDDLE) {
props.onWithdrawMiddle();
} else if (props.stoneType === StoneTypes.ON_DISCARD_WEST) {
props.onWithdrawLeft();
}
}
function applyDropResult(props, result) {
if (props.stoneType === StoneTypes.ON_WITHDRAW_MIDDLE || props.stoneType === StoneTypes.ON_DISCARD_WEST) {
if (result === null) …Run Code Online (Sandbox Code Playgroud) 我想使用自定义流来处理child_process.spawn stdio.
例如
const cp = require('child_process');
const process = require('process');
const stream = require('stream');
var customStream = new stream.Stream();
customStream.on('data', function (chunk) {
console.log(chunk);
});
cp.spawn('ls', [], {
stdio: [null, customStream, process.stderr]
});
Run Code Online (Sandbox Code Playgroud)
我收到错误Incorrect value for stdio stream.
有child_process.spawn https://nodejs.org/api/child_process.html#child_process_options_stdio的文档.它说stdio选项可以使用Stream对象
流对象 - 使用子进程共享引用tty,文件,套接字或管道的可读或可写流.
我想我错过了这个"指的"部分.