有没有可能创建pugjs组件,在那里我可以调用像x-button Sign In这样的组件
该组件将如下所示
button(class="py-3 px-8 rounded-lg inline-flex justify-center items-center font-semibold text-base leading-6 tracking-wide") #{text}与此概念类似的Laravel component
发布于 2021-01-23 03:55:02
这就是Pug mixins的用途:
// declare the mixin
mixin x-button
button.py-3.px-8.rounded-lg.inline-flex.justify-center.items-center.font-semibold.text-base.leading-6.tracking-wide
if block
block
// use the mixin
+x-button Sign In发布于 2021-01-23 00:16:38
组件的Pug等价物是template inheritance和includes。Includes将适用于您的用例:
//- includes/button.pug
button(class="py-3 px-8 rounded-lg inline-flex justify-center items-center font-semibold text-base leading-6 tracking-wide") #{text}//- some-page.pug
//- index.pug
doctype html
html
head
body
- var text = 'some-button-text'
include includes/button.pughttps://stackoverflow.com/questions/65848314
复制相似问题