简体   繁体   中英

How to passing a variable from pug to JS function

I am doing a JS function. that retrieve the variable from pub. What is the syntax should I put in.

i tried ${room.roomName} but it doesnt work.

Here is my code:

each room in rooms
   button(onclick="confirm(`${room.roomName}`)")= room.roomName

The error is: room is not defined at HTMLButtonElement.onclick.

If not too pretentious, you can easily get away with:

each room in rooms
   button(onclick="confirm(`${this.innerText}`)")= room.roomName

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM