大佬教程收集整理的这篇文章主要介绍了React JS 如何在函数内部呈现警报,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试创建一个登录页面,如果登录失败,我想显示一个错误。 我在这里调用函数: onClick={ this.login } 但我希望该函数显示错误消息而无需重新渲染所有内容。函数在一个类中
尝试这样的事情:
def create_tf_example(filepath,df_label):
encoded_image_data = open(filepath,"rb").read()
key = hashlib.sha256(encoded_image_data).hexdigest()
filename = os.path.basename(filepath)
image_name = filename.replace(".png","")
height0 = df_label["height0"].loc[df_label["id"]==image_name].iloc[0]
width0 = df_label["width0"].loc[df_label["id"]==image_name].iloc[0]
image_format = b'png'
width = 256
height = 256
xmins = [x / width0 for x in df_label["xmins0"].loc[df_label["id"]==image_name].iloc[0]]
xmaxs = [x / width0 for x in df_label["xmaxs0"].loc[df_label["id"]==image_name].iloc[0]]
ymins = [x / height0 for x in df_label["ymins0"].loc[df_label["id"]==image_name].iloc[0]]
ymaxs = [x / height0 for x in df_label["ymaxs0"].loc[df_label["id"]==image_name].iloc[0]]
classes_text = ["opacity".encode("utf-8")]*len(xmins) # now it creates a list of Strings with length equal to the number of bbox
classes = [0]*len(xmins) # now it creates a list of int with length equal to the number of bbox
tf_example = tf.Train.Example(features=tf.Train.Features(feature={
'image/height': tf.Train.Feature(int64_list=tf.Train.Int64List(value=[height])),'image/width': tf.Train.Feature(int64_list=tf.Train.Int64List(value=[width])),"image/filename": tf.Train.Feature(bytes_list=tf.Train.bytesList(value=[filename.encode("utf-8")])),"image/source_id": tf.Train.Feature(bytes_list=tf.Train.bytesList(value=['0'.encode("utf-8")])),# Pb with image names solved with this hack
"image/key/sha256": tf.Train.Feature(bytes_list=tf.Train.bytesList(value=[key.encode("utf-8")])),"image/encoded": tf.Train.Feature(bytes_list=tf.Train.bytesList(value=[encoded_image_data])),"image/format": tf.Train.Feature(bytes_list=tf.Train.bytesList(value=["png".encode("utf-8")])),"image/object/bbox/xmin": tf.Train.Feature(float_list=tf.Train.FloatList(value=xmins)),"image/object/bbox/xmax": tf.Train.Feature(float_list=tf.Train.FloatList(value=xmaxs)),"image/object/bbox/ymin": tf.Train.Feature(float_list=tf.Train.FloatList(value=ymins)),"image/object/bbox/ymax": tf.Train.Feature(float_list=tf.Train.FloatList(value=ymaxs)),"image/object/class/text": tf.Train.Feature(bytes_list=tf.Train.bytesList(value=classes_text)),"image/object/class/label": tf.Train.Feature(int64_list=tf.Train.Int64List(value=classes)),}))
return tf_example
,
通过创建一个不可见的警报来了解如何做到这一点,当我为错误设置一个变量时该警报是可见的
{
this.state.status &&
<Alert severity="error">
<Alerttitle>Error</Alerttitle>
{ this.state.status }
</Alert>
}
以上是大佬教程为你收集整理的React JS 如何在函数内部呈现警报全部内容,希望文章能够帮你解决React JS 如何在函数内部呈现警报所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。