如何解决隐藏/显示离子卡元素reactJS
我对ReactJS和Ionic还是比较陌生,但是我试图在使用函数的隐藏/显示和按如下所示的按钮中调用函数之间进行切换:
function myFunction(q1:string,q2:string) {
var x = document.getElementById(q1);
var y = document.getElementById(q2);
if(x !== null){
if (x.style.display === "none") {
x.style.display = "block";
y.style.display = "none";
} else {
x.style.display = "none";
y.style.display = "block";
}
}
}
我收到以下错误消息:y对象可能为null,但正在努力解决该问题。相应的html如下
<IonCard id="q1">
<IonCardHeader>
<IonCardSubtitle>Quiz 1</IonCardSubtitle>
<IonCardTitle>Question 1</IonCardTitle>
</IonCardHeader>
<IonCardContent>
<IonImg src={require("../../Images/Hello.gif")}/>
<br></br>
<IonButton expand="full" >Goodbye</IonButton>
<br></br>
<IonButton expand="full" onClick={() =>myFunction("q1","q2")} >Hello</IonButton>
<br></br>
<IonButton expand="full" >Excuse Me</IonButton>
<br></br>
<IonButton expand="full" >Test</IonButton>
</IonCardContent>
</IonCard>
<IonCard id="q2">
<IonCardHeader>
<IonCardSubtitle>Quiz 1</IonCardSubtitle>
<IonCardTitle>Question 2</IonCardTitle>
</IonCardHeader>
<IonCardContent>
<IonImg src={require("../../Images/Hello.gif")}/>
<br></br>
<IonButton expand="full" >Goodbye</IonButton>
<br></br>
<IonButton expand="full" >Hello</IonButton>
<br></br>
<IonButton expand="full" >test</IonButton>
<br></br>
<IonButton expand="full" >tester</IonButton>
</IonCardContent>
</IonCard>
非常感谢任何帮助,
解决方法
您可以使用useState挂钩:
Configuration conf = HBaseConfiguration.create();
conf.addResource(new Path(options.getHbsxml()));
HBaseAdmin.checkHBaseAvailable(conf);
让此示例正常工作:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。