扩展 React 类时覆盖单个(嵌套)属性 [英] Overwriting a single (nested) property when extending a React class

查看:32
本文介绍了扩展 React 类时覆盖单个(嵌套)属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 React.js 比较陌生,我相信我理解了主要概念,并且我正在努力寻找有关如何覆盖我声明的类的单个属性的文档.

I am rather new to React.js, I believe I understood the major concepts, and I am struggling to find documentation on how to overwrite a single property of a class I am declaring.

在我的一个组件中,我根据 Ant Design 中的类定义了一个新类 MyColumn.架构(继承而不是组合)已经由其他人完成,我无法更改.

In on of my components, I define a new class MyColumn based on a class from Ant Design. The architecture (of inheritance rather than composition) was already made by others, and I am not able to change that.

import { Table } from "antd";
const { Column } = Table;
// ... 
class MyColumn extends Column<Interfaces.myViewEntry> { }   // <---

目前,列标题只是向下流动,我需要省略号(以及带有完整列标签的鼠标悬停)或适当的自动换行.可能后者更容易.

At the moment, the column headers just flows downward, I need either ellipsis dots (and a mouse-over with the full column label), or a proper word wrap. Probably, the latter is easier.

为了达到这个目标,我想为 MyColumn 设置属性 style: { 'white-space': 'unset' } (以及那个属性),因为我读到这将使我能够为列标题获得正确的自动换行.

To reach that goal, I want to set the property style: { 'white-space': 'unset' } (and just that property) for MyColumn since I read that this will allow me to get proper word-wrap for the column headers.

有人可以详细说明在我用 <-- 标记的行中的括号中放入什么内容吗?

Could somebody please elaborate what to put into the brackets in the line I marked with <--?

interfaces.tsx中,我定义了如下内容

In interfaces.tsx, I defined something like the following

export interface myViewEntry{
    LastName: string,
    FirstName: string,
    Result: number,
}

参考资料

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆