小编Ali*_*ien的帖子

如何在 cypress 中执行 `cy.notContains(text)`?

我可以检查 cypress 中是否存在文本cy.contains('hello'),但现在我从页面中删除 hello,我想检查 hello 不存在,我该怎么做cy.notContains('hello')

javascript textmatching matcher cypress

18
推荐指数
2
解决办法
2万
查看次数

TypeScript 错误元素隐式具有“any”类型,因为“any”类型的表达式不能用于索引类型

我收到此错误:

  Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{ foo: string; bar: string; }'.ts(7053)
Run Code Online (Sandbox Code Playgroud)

在此代码中:

const CATEGORY_COLORS = {
  foo: '#6f79F6',
  bar: '#4fA0E9',
};

const CATEGORY_LABELS = {
  foo: 'FOO',
  bar: 'BAR',
};

const ItemRenderer = ({ item }: ItemRendererPropsType): React.ReactElement => {
  return (
    <div>
      <Tag color={CATEGORY_COLORS[item.category]}>
        {CATEGORY_LABELS[item.category]}
      </Tag>
    </div>
  );
};
Run Code Online (Sandbox Code Playgroud)

CATEGORY_COLORS[item.category]当我将鼠标悬停在 TypeScript或上时会出现错误CATEGORY_LABELS[item.category]。我该如何解决?

typescript reactjs

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