【问题标题】:I want to make a category and sub category select menu in pug and node.js. Where Subcategory changes based on category selected我想在 pug 和 node.js 中创建一个类别和子类别选择菜单。子类别根据选择的类别而变化
【发布时间】:2019-08-28 18:14:02
【问题描述】:

我知道如何使用 -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

【问题讨论】:

  • 你能发布一个你想要的输出html的例子吗?
  • 知道了。用jQuerry插件做的

标签: javascript jquery node.js express pug


【解决方案1】:

Pug 并非旨在进行动态(反应式)页面渲染。它是一个包含不同 JS 库的领域,例如 Reactjs 或 Vuejs。 Pug 是一个模板引擎,可以一次性渲染你的 HTML。

【讨论】:

    猜你喜欢
    • 2016-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多