我在使用react-native onPress功能时遇到问题.onPress应该仅在触摸事件(我猜)实际触发时才有效,即当我按下屏幕上的按钮时.但是当调用render函数时,似乎onPress会被触发.当我尝试手动按下时,它不起作用.
import React, { Component } from 'react';
import { PropTypes, Text, View ,Alert } from 'react-native';
import { Button } from 'react-native-material-design';
export default class Home extends Component {
render() {
return (
<View style={{flex:1}}>
<Button value="Contacts" raised={true} onPress={this.handleRoute('x')} />
<Button value="Contacts" raised={true} onPress={this.handleRoute('y')} />
<Button value="Contacts" raised={true} onPress={this.handleRoute('z')} />
</View>
);
}
handleRoute(route){
alert(route) // >> x , y, z
}
}
module.exports = Home;
Run Code Online (Sandbox Code Playgroud)
我错过了什么?我分配的方式有什么问题,或者这是一些错误吗?任何建议都非常感谢.
我尝试将项目推送到GitLab的存储库,但出现错误。
To https://gitlab.com/codersclan-interviews-frontend/codersclan-david-rose.git
! [remote rejected] test -> test (pre-receive hook declined)
error: failed to push some refs to 'https://gitlab.com/codersclan-interviews-frontend/codersclan-david-rose.git'
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
Git 存储库不是我创建的,它是客户端创建的。他让我把代码推送到我自己创建的分支上,完成后告诉他。
为了完成这项任务,我喜欢遵循
git clone https://gitlab.com/codersclan-interviews-frontend/codersclan-david-rose.git
git checkout -b 'test'
git branch test
add project
git add .
git commit -m "..."
git push origin test
Run Code Online (Sandbox Code Playgroud)
本以为推送结果会成功,但是却出现了上述错误。
我正在使用react-route,我在路由方面遇到了一些麻烦.
整个页面正在重新加载,导致我已经获取并存储在reducer中的所有数据每次都加载.
这是我的Route文件:
var CustomRoute = React.createClass({
render:function(){
return <Router history={browserHistory}>
<Route path="/" component={Layout}>
<IndexRedirect to="/landing" />
<Route path="landing" component={Landing} />
<Route path="login" component={Login} />
<Route path="form" component={Form} />
<Route path="*" component={NoMatch} />
</Route>
</Router>
},
});
Run Code Online (Sandbox Code Playgroud)
在路由之前,我已经通过调用main.jsx中的action来存储数据
/** @jsx React.DOM */
'use strict'
var ReactDOM = require('react-dom')
var React = require('react')
var Index = require('./components/index')
var createStore = require("redux").createStore
var applyMiddleware = require("redux").applyMiddleware
var Provider = require("react-redux").Provider
var thunkMiddleware = require("redux-thunk").default
var reducer = require("./reducers")
var injectTapEventPlugin =require('react-tap-event-plugin');
injectTapEventPlugin() …
Run Code Online (Sandbox Code Playgroud) 我有一个场景,当选择的输入超出焦点时必须触发一个事件.
当输入被聚焦时,已存在onFocus事件触发器
<input onFocus={this.callFunction}/>
Run Code Online (Sandbox Code Playgroud)
我需要知道当所选输入超出焦点时是否有可触发的事件.我在React表单站点找不到
<input outOfFocus={this.callFunction}/>
Run Code Online (Sandbox Code Playgroud)
对此的任何建议将受到高度赞赏.
我想点击fshare后打开一个窗口
我的render()
回报是这样的
<Modal.Footer>
<img src="/static/img/fshare.png" onClick={this.fbShare} />
<Button onClick={this.hide}>Close</Button>
</Modal.Footer>
Run Code Online (Sandbox Code Playgroud)
我正在创建一个函数
fbShare: function(event) {
},
Run Code Online (Sandbox Code Playgroud)
我想在函数中添加以下代码,基本上打开一个新窗口在Facebook中共享:
window.open('https://www.facebook.com/dialog/feed?app_id=xxxxxxxxe='sharer', 'toolbar=0,status=0,width=548,height=325');" target="_parent" href="javascript: void(0)">
Run Code Online (Sandbox Code Playgroud)
但我对如何处理此事件感到困惑.
任何建议将受到高度赞赏.提前致谢
我想知道div的滚动位置。
我左右有两个按钮,中间有一个可滚动的 div,里面填充了数据。
我想如果右侧没有数据则禁用右侧的按钮,如果左侧没有更多数据则禁用左侧的按钮。为此,我认为我需要知道当前的滚动位置。任何增强这一点的建议都会很棒。
` return <div className="row">
<div ref="previous_column" onClick={this.shift_left} href="#" style={style_div}></div>
<div className="table-container" ref="table_container">
<div className="sliding-window">
{this.props.grocery_cart.delivery_slots.map(function(obj) {
return <div key={d}>
<CalendarDetail values={d} ref="delivery_date"/>
</div>
}.bind(this))}
</div>
</div>
<div ref="next_column" href="#" onClick={this.shift_right} style={style_div} className="plr-slide"></div>
</div>`
Run Code Online (Sandbox Code Playgroud)
我刚刚添加了一些相关代码。
上一列和下一列是 div(左右按钮)
Table Container是一个固定的div,里面的滑动窗口可以滑动。
我有一种情况,我必须将字符串的前4个字符替换为'x'.
原始数据是'12345678'.我想替换为'xxxx5678'.
我实际上正在使用Jasper Reports,这是我的领域:
$F{obj.contact_id.hisher_member_id}
Run Code Online (Sandbox Code Playgroud)
任何建议将受到高度赞赏.
我有一个客户显示器,它连接到串行端口。为此,我正在使用 Windows 机器。
我想发送Ctrl+L来清除客户显示的显示,但我找不到对我有帮助的解决方案。基本上我希望Ctrl将来发送+'任何命令'。
在命令提示符中,我可以使用“ Ctrl+ L”清除现有显示并显示文本。以下是在提示符中显示的命令
echo ^LDisplay me > COMX // ^L is actually CTRL + L
Run Code Online (Sandbox Code Playgroud)
以上将输出为,
清除显示。
显示“显示我”
现在我正在尝试使用 Python 串行连接器来实现相同的目的。
import serial
ser = Serial ('COM5',timeout=2)
ser.write("\x0C") # equivalent to ctrl+L
Run Code Online (Sandbox Code Playgroud)
这根本行不通。我收到错误为`
串行连接异常:不支持unicode字符串,请编码为字节:'\x03'
但是,如果我对普通文本尝试以下操作,则效果很好,
ser.write("Display me".encode()
Run Code Online (Sandbox Code Playgroud)
这会在客户显示屏中显示“显示我”。
我尝试使用,ser.write("\x0C".encode())
但没有输出。
我得到错误
串行连接异常:不支持unicode字符串,请编码为字节:'\x1fc\x00'
我将不胜感激任何建议、改进和帮助解决这个问题。谢谢。
我正在尝试使用具有以下输出的 python3 创建一个简单的 XML 文件。
<products>
<product>
<id>1</id>
<name>Apple</name>
</product>
<product>
<id>2</id>
<name>Banana</name>
</product>
</products>
Run Code Online (Sandbox Code Playgroud)
我浏览了 xml.etree.ElementTree 但是我找不到如上完成的确切方法
我可以实现这样的目标
<products>
<product>
<id>1</id>
<name>Apple</name>
<id>2</id>
<name>Banana</name>
</product>
</products>
Run Code Online (Sandbox Code Playgroud)
以下是我使用的代码:
import xml.etree.cElementTree as ET
root = ET.Element("products")
doc = ET.SubElement(root, "product")
ET.SubElement(doc, "id").text = "some value1"
ET.SubElement(doc, "name").text = "some vlaue1"
ET.SubElement(doc, "id").text = "some value2"
ET.SubElement(doc, "name").text = "some vlaue2"
tree = ET.ElementTree(root)
tree.write("filename.xml")
Run Code Online (Sandbox Code Playgroud)
我想在根产品下创建不同的产品子元素。关于如何实现这一点的任何建议都会很棒。
我有一种情况,我想增加孩子们的父值.
家长:
getInitialState :function(){
return {counter:0}
},
render(){
<CallChild value={this.state.counter}/>
Run Code Online (Sandbox Code Playgroud)
儿童成分:有
render(){ this.props.counter++;}
什么建议吗?甚至可以做这样的事情.
我想在单击按钮时切换复选框。
这是我的 jQuery
$("#choose_address2").on("click", function () {
console.log("click!!! address2");
var $checkbox = $(this).find(':checkbox');
var checkBoxes = $("input[name=checkbox]]");
checkBoxes.prop("checked", !checkBoxes.prop("checked"));
});
Run Code Online (Sandbox Code Playgroud)
这是我的输入
<span id="choose_address2" class="btn btn-info">
<i class="fa fa-plus-circle"></i>????????????
<input type="checkbox" name="choose_address" {{#if customer.addresses}}checked{{/if}} id="choose_address1" hidden>
</input></span>
Run Code Online (Sandbox Code Playgroud)
默认情况下,该按钮处于选中状态。但是,当我单击带有 id 的跨度时,choose_address2
我想更改状态。任何建议将不胜感激。
reactjs ×5
javascript ×3
jquery ×2
python-3.x ×2
checkbox ×1
git ×1
gitlab ×1
html ×1
java ×1
modal-dialog ×1
onfocus ×1
pyserial ×1
python ×1
react-router ×1
scroll ×1
string ×1
windows ×1
xml ×1