【问题标题】:FramerJS, design to code, array loopFramerJS,设计到代码,数组循环
【发布时间】:2018-02-12 12:53:04
【问题描述】:

我一直在尝试通过设计选项卡中的设计列表元素上的虚拟数组创建循环。我看到数组正在循环中加载。我似乎无法将列表项放在一起。

尝试修复了很长时间后,有人可以指出我做错了什么吗?

for title in titleArray
    newItem = titleArray[title] = listItem.copy()
    newItem.y=(newItem.height)*title+58

    newItem.parent= scroll.content
    listItem.parent = scroll.content

https://framer.cloud/QdVJT

【问题讨论】:

    标签: arrays loops framerjs


    【解决方案1】:

    遍历数组时,会得到数组的元素而不是索引,要获取索引,可以在逗号后添加另一个变量:

    for title, index in titleArray
        newItem = listItem.copy()
        newItem.y = newItem.height * index
        newItem.selectChild("fieldTitle").text = title
    

    此处为完整示例:https://framer.cloud/BAnEq

    【讨论】:

    • 谢谢尼尔斯!太好了!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-08
    • 2015-02-13
    • 2019-11-21
    • 2011-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多