The backend gets the details of the article with the html tag, and how to add click events to the pictures inside.

get the details of an article with a html tag at the backend, and how to add click events to the images inside

what I use in vue is v-html for rendering. Is there any way to add click events to the picture?

Mar.04,2021

Thank you for the invitation,

you can bind the event (the node of v-html) to the parent element, determine whether it is a img tag according to e.target , and execute the operation

.

implemented in disguise. I don't know if it's feasible. The general idea is to use event bubbles

.

add the execution function to the click event on that component of the entire html (the parent element of all pictures)

then pass the event variable to the method

judge whether the picture has been clicked by event.target.nodeName=='IMG', and then proceed to follow-up business processing


  1. everything upstairs is basically true.
  2. it is not recommended to use "server-side rendering" + v-html to generate pages. On the one hand, this leaves a loophole in XSS attacks, on the other hand, it also causes serious coupling between the back end and the front end, which increases the maintenance cost in the future.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea938a-47d12.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea938a-47d12.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?