0

不确定标题是否有意义,但我在这里尝试做的是让 Pug 从这个country-region-data JSON 文件中显示特定国家/地区的区域,但没有成功。我确实设法让它显示所有国家及其地区,但这不是目标。

这是我的帕格:

- var countries = locals['countries']
  each country in countries.countryName == "Singapore"
    each region in country.regions
      option= region.name

我还是 Pug 和 JSON 的新手。从 JSON 文件中可以看出,countryNameis 是一个键,并且Singapore是一个键的值(这里的术语是否正确?)

我真的希望有人能提供一些启示!

先感谢您。

4

1 回答 1

0

好的,找到了解决方案!

select.form-control(id="address_state")
  - var states = locals['countries']
    each val, key in countries
      if val.countryName == 'Malaysia'
        each region, key in val.regions
          option= region.name
于 2017-07-13T13:32:13.177 回答