我知道如何使用
-var={}
并在其中添加值和名称,但对于我的工作流程,我想要一个类别菜单,其中包含电子,体育等类别,因此,如果我选择体育项目,则其他子类别菜单仅显示不同的体育项目。我需要使用一种表单动态地进行操作,并且值应该更改而无需单击提交按钮
但它仅呈现一个菜单
-var selected=''
-var dic ={ 'Sports': 'Sports', 'Tech': 'Tech'};
select.custom-select
option(selected='') Open this select menu
for key,value in dic
option(value=key)=value
selected=value
if selected==='Sports'
select.custom-select
option(selected='') Open this select menu
option(value='1') football
option(value='2') cricet
if selected === 'Tech'
select.custom-select
option(selected='') Open this select menu
option(value='1') Mobile
option(value='2') Tablets
答案 0 :(得分:0)
Pug不能进行动态(反应性)页面渲染。它是不同的JS库(例如Reactjs或Vuejs)的领域。 Pug是一个模板引擎,只会渲染一次HTML。