小编Rui*_*Rui的帖子

使用React中父组件中的Button提交表单

形式模态

所以我必须在模态中实现一个表单,如你所见,模态中的按钮不是表单中的按钮.我创建了表单作为模态的子组件.如何使用父组件中的按钮提交表单.我正在使用React Semantic-UI作为我的UI框架.

我想如果我可以隐藏表单中的按钮并使用JavaScript触发它.我认为这可以通过getElementById来实现,但有没有做出反应的方式呢?

我目前的Modal看起来像这样:

<Modal open={this.props.open} onClose={this.props.onClose} size="small" dimmer={"blurring"}>
    <Modal.Header> Edit Activity {this.props.name} </Modal.Header>
    <Modal.Content>
      <ActivityInfoForm/>
    </Modal.Content>
    <Modal.Actions>
        <Button negative onClick={this.props.onClose}>
            Cancel
        </Button>
        <Button positive
                content='Submit'
                onClick={this.makeActivityInfoUpdateHandler(this.props.activityId)} />
    </Modal.Actions>
</Modal>
Run Code Online (Sandbox Code Playgroud)

我的表单代码如下所示:

<Form>
    <Form.Group widths='equal'>
        <Form.Input label='Activity Name' placeholder='eg. CIS 422' />
        <Form.Input label='Activity End Date' placeholder='Pick a Date' />
    </Form.Group>
    <Form.Group widths='equal'>
        <Form.Input label='Total Capacity' placeholder='eg. 30' />
        <Form.Input label='Team Capacity' placeholder='eg. 3' />
    </Form.Group>
</Form>
Run Code Online (Sandbox Code Playgroud)

javascript html5 node.js web reactjs

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

Google Map API setCenter方法不起作用

所以我必须在我的页面上添加一个"中心"按钮,当点击时,地图将使用setCenter方法在引脚上居中.但是,在我单击我的按钮后,地图变为空白而不是显示中心.

这是我的代码.

如何解决问题?先感谢您!

<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script>
  function init() {
    var addButton = document.getElementById("setcenter");
    addButton.onclick = handleSetCenterButtonClicked;
    getMyLocation();
  }


  window.onload = init;

  function getMyLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(displayLocation);
    } else {
        alert("Oops, no geolocation support");
    }
  }

  function displayLocation(position) {
    showMap(position.coords);
    var latitude = position.coords.latitude;
    var longitude = position.coords.longitude;
    var div = document.getElementById("location");
    div.innerHTML = "You are at Latitude: " + latitude + ", Longitude: " + longitude;
  }

  var map;
  function showMap(coords) {
    var googleLatAndLong = new google.maps.LatLng(coords.latitude, coords.longitude); …
Run Code Online (Sandbox Code Playgroud)

javascript api google-maps geolocation

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

如何在Python递归函数中将具有多个值的变量相加?

所以我在网上研究递归函数.并且一个问题要求我编写一个函数来将数字的数字加在一起.例如(1023) - > 1 + 0 + 2 + 3 = 6.我使用%和//每次都去掉一个数字.但是,我不知道如何将它们加在一起.我能得到的最接近的是打印出每个数字.任何人都可以帮我解决或者给我一个提示吗?

def digitalSum(n):
    if n < 10:
        sum_total = n
        print(sum_total)
    else:
        sum_total = n % 10
        digitalSum((n - (n % 10))//10)

        print(sum_total)

digitalSum(1213)
Run Code Online (Sandbox Code Playgroud)

python recursion

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

标签 统计

javascript ×2

api ×1

geolocation ×1

google-maps ×1

html5 ×1

node.js ×1

python ×1

reactjs ×1

recursion ×1

web ×1