[英]How to Call functions in Jade file from Javascript
I am using Jade language in my code. 我在代码中使用Jade语言。 I have written some jade functions with the help of mixin syntax.
我已经在mixin语法的帮助下编写了一些玉器功能。 Now I wanted to call that functions from javascript code.
现在,我想从javascript代码中调用该函数。
How do I call ? 我怎么打? Can anybody help me please.
有人可以帮我吗。
ul.grid
each product in products
+productItem(product)
mixin productItem(item)
li(style="border: 1px solid #ddd;margin-top: 35px;") #{item}
script(type='text/javascript').
console.log("Welcome");
<<How to call productItem function >>
I wanted to call the productItem function from script tag where I written <> this sentence. 我想从我写<>这句话的脚本标记中调用productItem函数。 Please help me.
请帮我。
You cannot call Pug mixins with JS. 您不能使用JS调用Pug mixins。 And mixins aren't functions either.
而且,mixins也不起作用。 That said, you can include Javascript in a mixin like this:
也就是说,您可以像这样在mixin中包含Javascript:
mixin productItem(item)
li(style="border: 1px solid #ddd;margin-top: 35px;") #{item}
script.
console.log("This will be logged once each time this mixin is called.");
Is it correct to assume, that you would like to include JS in your PUG mixin? 假设您想在您的PUG mixin中包含JS是否正确?
Btw, Jade is now Pug . 顺便说一句, 玉现在是帕格 。 Cheers!
干杯!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.