提问者:小点点

用于typescript的CSS接口


Typescript中有CSS接口吗?我想定义我的接口,这将扩展它。像这样的东西:

export interface IComponentProperties extends ICSS {
    title: string,    
    text?: string,  
    resizable?: boolean,
    connectToParent?:  string | HTMLElement,
    replaceParentContent?: boolean,
}

如果没有任何css接口,我的接口应该是这样的:

export interface IComponentProperties{
    // CSS props
    width?: string,
    height?: string,
    backgroundColor?: string,
    display?: string,
    position?: string,
    left?: string,
    right?: string,
    transition?: string,
    "z-index"?: string,
    "flex-direction"?: string,

    // Component props
    title: string,    
    text?: string,  
    resizable?: boolean,
    connectToParent?:  string | HTMLElement,
    replaceParentContent?: boolean,
}

并且我必须在那里指定我最终将使用的每个css属性。。。那么有没有CSS接口,我可以扩展?

谢啦!


共1个答案

匿名用户

存在,但请注意,当属性值不存在时,将给出空字符串而不是:

null

const { style } = document.createElement('div');
console.log(style.height, typeof style.height, style.height.length);