小编Pan*_*str的帖子

有没有办法检查十六进制颜色 - Cypress

我目前正忙于在 Cypress 上进行测试。我实际上是新手,所以我对周围的一切都不太熟悉,但我正在尝试测试background-color某些元素的 CSS 属性,但问题是幕后一切都是 RGB,但我需要在 HEX 上进行测试。所以我问自己有没有办法做到这一点或者应该需要翻译?

  cy.get('#button-login')
   .should('have.css', 'background-color', "#6a7ba3")
Run Code Online (Sandbox Code Playgroud)

错误 ...to have CSS property 'background-color' with the value '#6a7ba3', but the value was 'rgb(106, 123, 163)'

javascript testing cypress

6
推荐指数
1
解决办法
4593
查看次数

受控禁用按钮 Material UI - React JS

我有一个快速的问题 。我正在尝试有条件地禁用按钮。基本上,如果从我的表中选择了某些内容,那么我允许该按钮可用,否则它将被禁用。我知道 MUI 需要一个布尔值来禁用或启用按钮,因此从我的数组中我正在执行一个forEach循环并获取所选值。但即使我认为我具有 selected 的值,似乎也没有发生任何事情。有什么想法我做错了什么吗?我的数组:

data: [{
 ....
 selected : true / false
 ....
}]
Run Code Online (Sandbox Code Playgroud)

我的按钮:

 <Tooltip title='Download'>
        <Button
            className={classes.root}
            key='DownloadAll'
            disabled={data.forEach(element => element.selected)}
            color='primary'
            onClick={(event) => buttonOnClick()}
        >
            <SvgIcon
                component={faDownload}
            />
        </Button>
    </Tooltip>
Run Code Online (Sandbox Code Playgroud)

javascript reactjs material-ui

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

AdBlock 到 ReactJs 中

我正在努力寻找解决方案,到目前为止没有任何进展。我试图捕获用户是否有 AdBlocker,如果有,我想显示一条消息,建议他将其关闭。但是,到现在为止还没有成功。

我将我的组件导入到我的主容器中,例如:

<DetectAdBlock pathname={window.location.pathname} />

Run Code Online (Sandbox Code Playgroud)

这是我的 adblocker.js

import React from 'react';
import PropTypes from 'prop-types'

class DetectAdBlock extends React.Component {

    static propTypes = {
        pathname: PropTypes.string.isRequired
};

    constructor(props) {
        super(props);
        this.state = {
            adBlockDetected: false
        }
        this.detectAdBlocker = this.detectAdBlocker.bind(this);
   }
    componentDidMount() {
        this.detectAdBlocker();
    }
    componentWillUpdate(nextProps, nextState) {
        if (this.props.pathname !== nextProps.pathname) {
            this.detectAdBlocker();
        }
    }
    detectAdBlocker() {
        const head = document.getElementsByTagName('head')[0];

        const noAdBlockDetected = () => {
            this.setState({
                adBlockDetected: false
            });
        }
        const adBlockDetected = () => {
            this.setState({ …
Run Code Online (Sandbox Code Playgroud)

adblock reactjs

4
推荐指数
1
解决办法
3834
查看次数

“材料表” - 如何为每页添加更多行并修复渲染 - ReactJs

我正在尝试将每页更多行应用到我的表格中material-table。到现在为止,我发现您可以添加一个数组,其中包含每页如一厢情愿的行。rowsPerPageOptions={[5, 10, 25, 50, 100]} ,但我的问题是当我应用 100 行时,表格会扩展到空白行。(我目前只从后端收到 24 行(文档))所以基本上它必须限于我拥有的数据。有人可以帮我一把吗?谢谢

 divideItems = () => {

        let startIndex = ((parseInt(this.state.activePaginationTab) + 1) * this.state.rowsPerPage) - this.state.rowsPerPage;
        let endIndex = (parseInt(this.state.activePaginationTab) + 1) * this.state.rowsPerPage - 1;
        let tabItems = [];

        for (let i = startIndex; i <= endIndex; i++) {
            if (this.state.items[i]) {
                tabItems.push(this.state.items[i]);
            }
        }


        this.setState({
            tabItems
        }, () => {

        });

    }
    getNewIndex = (event, page) => {
        this.setState({
            activePaginationTab: page
        }, () => { this.divideItems() …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs material-table

4
推荐指数
3
解决办法
6824
查看次数

如何从子级调用父级函数-react-native

我正在努力寻找解决问题的方法,但是在任何地方都无法找到它。所以我的问题是如何从孩子那里调用父函数。该函数具有在将被传递onPress = {()}的子内

Parent.js

   constructor(props) {
    super(props);
    this.state = { loading: true };
    this.state = { active: 'active' };
    this.openDrawer = this.openDrawerButtonFunction.bind(this);
    this.callParent = this.callParent.bind(this)

       }

     callParent = () => {
     console.log('I am your father')   }
Run Code Online (Sandbox Code Playgroud)

Child.js

     <Avatar
      avatarStyle={{ height: 50 }}
      onPress={() => { this.onPressAvatar() }}
      source={require('../../assets/images/dav-r.jpeg')} />

      onPressAvatar = () => {
      console.log('press on avatar');
        this.props.callParent.bind(this)
Run Code Online (Sandbox Code Playgroud)

}

javascript reactjs react-native react-native-android react-native-ios

3
推荐指数
1
解决办法
2080
查看次数

“材料表” - 有没有办法从表中分离过滤。- ReactJs

嘿伙计们,我不知道这是否可行,但我想在表外的单独组件上使用下拉列表进行过滤,但仍要过滤当前表。这件事可能吗?如果是的话,我可以举个例子吗?在此处输入图片说明

javascript reactjs material-table

1
推荐指数
1
解决办法
1809
查看次数