小编Sle*_*uue的帖子

Add a section not working in Shopify Theme development

I have made a few websites before using a shopify theme and I am trying my best to develop my own theme. I understand how sections work, and I can add the sections that I have created in statically, but I cannot dynamically from the theme customizer. Has this happened to anyone before or know of a way to fix it? Instead of being able to choose a section after clicking add a section I just get the message

"This …

themes shopify

5
推荐指数
1
解决办法
3394
查看次数

查找列表的"居中平均值"

"返回整数列表的"居中"平均值,我们会说这是值的平均值,除了忽略列表中的最大值和最小值.如果有最小值的多个副本,则忽略一个复制,同样为最大值.使用整数除法产生最终平均值.您可以假设列表长度为3或更长."

这是我在家庭作业中遇到的一个问题,我很难找到如何找到最大/最小的数字并将它们从列表中删除.这是我到目前为止所拥有的.它适用于10/14我必须通过的场景..我认为这只是因为它抓住了中位数

def centered_average(nums):
x = 0
for i in range(len(nums)):
    x = i + 0
y = x + 1
if y%2 == 0:
    return (nums[y/2] + nums[(y/2)+1]) / 2
else:
    return nums[y/2]
Run Code Online (Sandbox Code Playgroud)

python algorithm

2
推荐指数
1
解决办法
3808
查看次数

标签架构中的 JSON 无效

嘿伙计们,我对 Shopify 真的很陌生。并尝试学习液体。我在 schema/ 中收到无效的 JSON 标记,但我不太确定它在哪里。我只是想拥有 4 个基本块,您可以将它们添加到下面带有图像和标题的部分。我现在没有制作内容块,因为我一开始就无法让图像工作。

{% for block in section.blocks %}
  <div class="grid-item" {{ block.shopify_attributes }}>
  {% case block.type %}
  {% when 'image' %}
    <img src="{{ block.settings.image | img_url }}">

</div>
  {% when 'text' %}
    {{ block.settings.content }}
  {% endcase %}
{% endfor %}

{% schema %}
  {
    {
    "blocks": [
      {
       "name": "Service",
       "limit": 4
       "settings": [
          {
          "type": "image_picker",
          "id": "image",
          "label": "image"
          }
        ]
      }
    ]
  }
  }
{% endschema %}
Run Code Online (Sandbox Code Playgroud)

再说一遍,就像我说的,我对这一切真的很陌生,所以任何正确方向或帮助的点都会非常棒!谢谢!

schema json liquid shopify

1
推荐指数
1
解决办法
4642
查看次数

如何将javascript数组转换为格式化的JSON字符串

可以说我有一个看起来像这样的对象:

var test = {
    jsonString: {
        groups: ['1','2','3','4','5']
    }

}
Run Code Online (Sandbox Code Playgroud)

我怎么能让它看起来像这样的json字符串?

var test = {
    jsonString: "{\"groups\":[\"1\",\"2\",\"3\",\"4\",\"5\"]}"
  }
Run Code Online (Sandbox Code Playgroud)

我对如何做到这一点有点失落.而且我认为JSON.stringify(test.jsonString)不会做我需要的确切技巧,但我可能只是做错了.任何帮助或任何方向看哪里都会很棒!谢谢!

javascript arrays json

-1
推荐指数
1
解决办法
39
查看次数

标签 统计

json ×2

shopify ×2

algorithm ×1

arrays ×1

javascript ×1

liquid ×1

python ×1

schema ×1

themes ×1