我的反应应用程序中有页码。现在,当我点击页码时,点击或当前页码不会突出显示或以不同颜色显示。我有一个className =“text-success”,如果添加它将使文本变为绿色。我想将它动态添加到单击的数字。我应该怎么做
这是分页div(页面nunbers)
<div className="pagination-media">
<a href="#" onClick={this.getPreviousPage} className="text-success">
<span className="fa fa-chevron-left"></span>
PREV
</a>
{page_number_array.map((item, i) => (
<a href="#" id={`page-${item}`} className="page-no-m"
onClick={() => this.pageNumberClicked(item)}>{`${item} `}</a>
)
)}
<a href="#" onClick={this.getNextPage}
className="text-success"><b>NEXT</b>
<span className="fa fa-chevron-right"></span></a>
</div>
答案 0 :(得分:1)
您需要将line1 checked
line2 checked
line3 checked
...
保存在状态中才能知道当前活动的网页是什么。然后,您可以有条件地将line1
line2
line3
checked checked checked
类添加到每个链接:
tf.reset_default_graph()
if FLAGS.job_name == "ps":
server.join()
elif FLAGS.job_name == "worker":
# Between-graph replication
with tf.device(tf.train.replica_device_setter( worker_device="/job:worker/task:%d" % FLAGS.task_index, cluster=Cluster)):
## here defining my model, cost, optimizer
sv = tf.train.Supervisor(is_chief=(FLAGS.task_index == 0), global_step=global_step, init_op=init_op)
with sv.prepare_or_wait_for_session(server.target) as sess:
for epoch in range(training_epochs):
cost_val = sess.run([ cost ], feed_dict={X: data})
currentPage
text-success