我为什么不能用Typescript散布道具?

时间:2019-06-04 00:22:38

标签: reactjs typescript

因此,该方法不会出现任何打字稿错误:

for contour in contours:

    rect = cv.minAreaRect(contour)
    box = cv.boxPoints(rect)
    box = np.int0(box)
    Cx = rect[0][0]
    Cy = rect[0][1]

    # Make a mask of this single green line
    mask = np.zeros_like(mask1)
    cv.drawContours(mask, [contour], 0, 255, cv.FILLED)
    sigle_green_line = cv.bitwise_and(image, image, mask = mask)
    sigle_green_line = cv.cvtColor(sigle_green_line, cv.COLOR_BGR2HSV)
    # Check how much blue is in the image
    blue_mask = cv.inRange(sigle_green_line, low_blue, high_blue)
    print(sum(sum(blue_mask)))
    # If the image is not all black (all zeros) the contour contains some blue
    if sum(sum(blue_mask)) > 0: print('This contour contains some blue')

但这给我一个错误:

<Box hAlign={"RIGHT"} vAlign={"CENTER"} />;

...

const commonBoxProps = {
  hAlign: "RIGHT",
  vAlign: "CENTER",
};

错误:

<Box {...commonBoxProps} />;

1 个答案:

答案 0 :(得分:0)

您可以使用样式化的组件来做到这一点:

const ColumnBox = styled(Box).attrs({
  hAlign: "RIGHT",
  vAlign: "CENTER",
})``;