小编Sto*_*ace的帖子

无法中断 for 循环:非语法中断

我想break一个for-loop当满足特定条件

Object.keys(s).map(uk => {
    Object.keys(s[uk]).map(ik => {
        for (let i = 1; i < data.length; i++) {
            if (...) {
                s[uk][ik].map(elem => {
                    if (...) {
                        if (...) {
                            data.push(...);
                            break;
                            ...
Run Code Online (Sandbox Code Playgroud)

然而,break声明给了我一个

不合语法的中断

这是为什么?它应该只是一个breakfor-loop,还是JavaScript认为我想打破map

javascript

9
推荐指数
3
解决办法
3万
查看次数

单击 Material UI &lt;Button /&gt; 更改波纹颜色

这是我的<MyButton />组件

import React from 'react';
import { withStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';

const styles = theme => ({
  button: {
    backgroundColor: 'green',
    "&:hover": {
      backgroundColor: "red"
    },
  },
});

function MyButton(props) {

  return (
    <Button
      className={props.classes.button} >
      {props.text}
    </Button>
  );
}

export default withStyles(styles)(MyButton);
Run Code Online (Sandbox Code Playgroud)

目前,按钮上有默认的点击效果,点击时使其变亮/变亮(请参阅此处:https : //material-ui.com/demos/buttons/)。但是,我希望blue单击按钮时“波纹”的颜色是。

我试过

"&:click": {
    backgroundColor: "blue"
},
Run Code Online (Sandbox Code Playgroud)

"&:active": {
    backgroundColor: "blue"
},
Run Code Online (Sandbox Code Playgroud)

虽然没有运气。单击按钮时如何更改波纹的颜色?

javascript reactjs material-ui

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

通过 Ruby 安装 Cocoapods 导致错误

我尝试像这样安装 Cocoapods

sudo gem install cocoapods

这是我得到的输出:

Building native extensions. This could take a while...
ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20210206-1353-ybitkb.rb extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME) …
Run Code Online (Sandbox Code Playgroud)

ruby macos xcode rubygems cocoapods

8
推荐指数
2
解决办法
5521
查看次数

两个GeoSeries的指数不同 - 了解指数

我正在工作,GeoPandas并且我有两个GeoDataframes相同的CRS. 其中一个包含一列带有geometry多边形的列geometry,另一列包含带有点的列geometry。我想检查哪些点在多边形内。

我天真地尝试过

shape.contains(points)
Run Code Online (Sandbox Code Playgroud)

这给了我

>  The indices of the two GeoSeries are different
Run Code Online (Sandbox Code Playgroud)

我不明白这个消息。当我检查文档时,它说

我们还可以逐行检查两个 GeoSeries。上面的 GeoSeries 有不同的索引。我们可以根据索引值对齐两个 GeoSeries 并使用align=True 比较具有相同索引的元素,或者忽略索引并使用align=False 根据匹配顺序比较元素:

这些指数是什么?为什么它们是相互检查的而不是geometry columns?我在网上读到,我必须将我的几何图形转换为shapely几何图形。GeoPandas但是,使用数据进行地理操作的全部目的不就是这样吗?

我对此很困惑。如何检查geometriesin是否shape包含任何geometriesin points

python geospatial geo geopandas

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

将多边形列表合并为多多边形

我有一个匀称多边形的列表

myList = [[<shapely.geometry.polygon.Polygon object at 0x110e09d90>], [<shapely.geometry.polygon.Polygon object at 0x110e09f90>], [<shapely.geometry.polygon.Polygon object at 0x110ec9150>]]
Run Code Online (Sandbox Code Playgroud)

我将如何创建MultiPolygon它们?我无法理解它

python geospatial shapely

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

更改默认文本颜色材质 UI

我在哪里可以更改 Material UI 主题中的默认文本颜色?

设置primarysecondary以及error作品

const styles = { a: 'red', b: 'green', ... };

createMuiTheme({
    palette: {
        primary: {
          light: styles.a,
          main: styles.b,
          dark: styles.c,
          contrastText: styles.d
        },
        secondary: {
          light: styles.aa,
          main: styles.bb,
          dark: styles.cc,
          contrastText: styles.dd
        },
        error: {
          light: styles.aaa,
          main: styles.bbb,
          dark: styles.ccc,
          contrastText: styles.ddd,
        },
    ...,
    }
...,
}
Run Code Online (Sandbox Code Playgroud)

现在,当我使用<Typography />组件时,我可以这样做

<Typography
  color='primary'
  variant='h6'>
  Foo
</Typography>
Run Code Online (Sandbox Code Playgroud)

这给了它我在palette.primary.main.

但是,当我将color道具留空时

<Typography
  variant='h6'>
  Foo
</Typography> …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs material-design material-ui

7
推荐指数
2
解决办法
4387
查看次数

如何将本地主机拉入本地分支

我有一个远程origin/master和远程分支remote_branch.我也有本地master和当地的分支机构local_branch.当我试图把当地人拉master进去的时候local_branch,git pull master local_branch我得到了这个.

fatal: 'master' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)

但是,当我这样做时,git branch我看到了这个:

* loca_branch
  master
Run Code Online (Sandbox Code Playgroud)

为什么我不能从当地拉master

git github

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

在传单上叠加div而不是点击

如何div在传单地图上覆盖而不是点击?我把我试过pointer-events: noneauto,在重叠的div,但这并没有帮助.设置pointer-eventsnone有这样的效果radiobutton是不可点击了...

// We’ll add a tile layer to add to our map, in this case it’s a OSM tile layer.
// Creating a tile layer usually involves setting the URL template for the tile images
var osmUrl = 'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
  osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  osm = L.tileLayer(osmUrl, {
    maxZoom: 18,
    attribution: osmAttrib
  });

// initialize the map on the "map" div with a given center and …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery leaflet

6
推荐指数
2
解决办法
5000
查看次数

外部函数中的setState / use State反应

考虑以下伪代码:

component.js

...
import {someFunc} from "./common_functions.js"

export default class MyComp extends Component {
    constructor(props) {
        super(props);

    this.someFunc = someFunc.bind(this);

    this.state = {...};
    }

    _anotherFunc = () = > {
        ....
        this.someFunc();
    }

    render() {
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

common_functions.js

export function someFunc() {
    if(this.state.whatever) {...}
    this.setState{...}
}
Run Code Online (Sandbox Code Playgroud)

我如何将函数绑定someFunc()到的上下文Component?我在各种组件中使用它,因此将它们收集在一个文件中是很有意义的。现在,我收到错误消息“无法读取任何未定义的内容”。的上下文this未知...

javascript reactjs react-native

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

检查复选框是否被笑话/酶选中

如何测试是否选中了多个复选框?

render()
    ...
        <React.Fragment>
              <div
                className='foo'>
                <label>
                  <input
                    className='checkbox'
                    name='bar'
                    type='checkbox'
                    checked={this.props.checked}
                    onChange={() => { } }
                  />
                </label>
              </div>
        </React.Fragment>
    ...
Run Code Online (Sandbox Code Playgroud)

我试过

it('checks all checkboxes', () => {
    const component = shallow(
        <Foo
            ... />
    )

    expect(component
        .find('input[type="checkbox"][checked="checked"]'))
        .toHaveLength(content.length);
});
Run Code Online (Sandbox Code Playgroud)

component
    .find({ type: 'checkbox' })
    .forEach(node => {
        expect(node
            .props
            .checked)
            .toEqual(true);
    });
Run Code Online (Sandbox Code Playgroud)

或者

component
    .find('input')
    .forEach(node => {
        expect(node
            .props
            .checked)
            .toEqual(true);
    });
Run Code Online (Sandbox Code Playgroud)

component
    .find('.checkbox')
    .forEach(node => {
        expect(node
            .props
            .checked)
            .toEqual(true);
    });
Run Code Online (Sandbox Code Playgroud)

最后三个给我,undefined而第一个返回一个巨大的物体( …

javascript jestjs enzyme

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