【问题标题】:Render Jade / Pug from javascript variable从 javascript 变量渲染 Jade / Pug
【发布时间】:2017-01-31 17:06:52
【问题描述】:

我最近在与 Pug (Jade) 合作时遇到了一些麻烦。 我将一个数组从我的背部发送到我的前面,然后我在客户端对其进行排序。

看起来像这样:

potentials 是我使用 res.render('./myPage', {potentials}) 从背后发送到我前面的对象数组

script.

    $(document).ready(function() {
      $("#age-slider").change(function(){

        var slider = document.querySelector('#age-slider')
        var sliderInputs = slider.querySelectorAll('input[type=range]')
        var found_age = potentials.filter(v => v.age >= sliderInputs[0].value && v.age <= sliderInputs[1].value);
        console.log(found_age)

      })
    })
  if (found_age)
    span
      li
       found_age.username

所以我的排序工作正常我可以在使用输入时记录我的值但是我现在如何在这个哈巴狗页面上呈现我的数组found_age? 我有什么

感谢您的帮助!

【问题讨论】:

    标签: javascript node.js express pug


    【解决方案1】:

    经过一夜的挖掘,这对我有用:

    found_age = potentials.filter(v => v.age >= sliderInputs[0].value && v.age <= sliderInputs[1].value);
          console.log(found_age)
            document.getElementById('array-Filter').innerHTML = found_age.map((user) => {
                return `
                <li>${user.username}  ${user.age} years old from ${user.city}</li>
                `;
            }).join('');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-13
      • 2017-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-16
      • 1970-01-01
      • 2012-06-26
      相关资源
      最近更新 更多