I would like to ask you how to click the favorites button, the words "favorites" are displayed in the middle of the page, and the collection has been cancelled.

can you give me a detailed explanation of the train of thought, process and technology?
the key question is how to display words in the middle of the page

Mar.04,2021

if the front end is static, write a click event to directly determine whether the text has been collected, and if so, cancel it; otherwise, it will be collected.
if there is a front-end interaction, you need to pass a field to ensure that the data is refreshed directly


The

button has two states: [favorites] <-> [unfavorites]

when initializing the page, judge the current state according to the background data, and then assign a value to the innerHTML of the button

The

button binds the click event, reverses it according to the current state, and refreshes the interface that needs to be displayed

Menu