我在这个例子中使用Datamaps。我有一个数据图,当在this.setState is not a function
中单击时,会更改该部分的颜色。我还想在我的React状态中存储一个数字。但是,下面的代码会导致lemap:function(){
var map = new Datamap({
element: document.getElementById('maincontains'),
scope: 'usa',
fills: {defaultFill: 'rgb(217, 217, 217)'},
done: function(datamap) {
datamap.svg.select('.datamaps-subunit.MI').on('click', function(geography) {
var m = {};
var bis = this;
m[geography.id] = 'pink';
datamap.updateChoropleth(m);
this.setState({trumpnum: 12});
});
}
});
},
错误。
import boto.ec2
from boto.manage.cmdshell import sshclient_from_instance
# Connect to your region of choice
conn = boto.ec2.connect_to_region('us-west-2')
# Find the instance object related to my instanceId
instance = conn.get_all_instances(['i-12345678'])[0].instances[0]
# Create an SSH client for our instance
# key_path is the path to the SSH private key associated with instance
# user_name is the user to login as on the instance (e.g. ubuntu, ec2-user, etc.)
ssh_client = sshclient_from_instance(instance,
'<path to SSH keyfile>',
user_name='ec2-user')
# Run the command. Returns a tuple consisting of:
# The integer status of the command
# A string containing the output of the command
# A string containing the stderr output of the command
status, stdout, stderr = ssh_client.run('ls -al')
答案 0 :(得分:0)
通过在函数下方添加var sting = this
来修复它。
lemap:function(){
var sting = this;
var map = new Datamap({
element: document.getElementById('maincontains'),
scope: 'usa',
fills: {defaultFill: 'rgb(217, 217, 217)'},
done: function(datamap) {
datamap.svg.select('.datamaps-subunit.MI').on('click', function(geography) {
var m = {};
var bis = this;
m[geography.id] = 'pink';
datamap.updateChoropleth(m);
sting.setState({trumpnum: 12});
});
}
});
},