小编Rud*_*chi的帖子

shopify中的settings_data.json和settings_schema.json有什么区别

shopify中的settings_data.json和settings_schema.json文件有什么区别,我可以通过两者设置主题设置,但我到底什么时候会使用哪一个?我在下面给出了一个示例,其中显示了Setting_schema.json 文件和Setting_data.json 文件,但我可以理解两者都在管理部分中创建相同的功能。但那有什么区别呢。为什么shopify主题使用两种类型的设置json文件?

/**Here is Setting_schema.json file :**/

[
  {
    "name": "theme_info",
    "theme_name": "Minimal",
    "theme_author": "Shopify",
    "theme_version": "1.0",
    "theme_documentation_url": "https:\/\/docs.shopify.com\/manual\/more\/official-shopify-themes\/minimal",
    "theme_support_url": "https:\/\/support.shopify.com\/"
  },
  {
    "name": "Layout",
    "settings": [
      {
        "type": "checkbox",
        "id": "enable_wide_layout",
        "label": "Enable wide layout"
      }
    ]
  },
  {
    "name": "Colors",
    "settings": [
      {
        "type": "header",
        "content": "Background"
      },
      {
        "type": "checkbox",
        "id": "theme_bg_image",
        "label": "Use theme background"
      },
      {
        "type": "image_picker",
        "id": "bg_custom",
        "label": "Custom image"
      },
      {
        "type": "radio",
        "id": "bg_image_display",
        "label": "Image display",
        "options": [ …
Run Code Online (Sandbox Code Playgroud)

json shopify

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

具有相同功能的多个事件侦听器存储单独的局部变量?

我对javascript中的闭包很新(当然在将它们应用于事件处理程序时!),并试图掌握导致此代码行为的基本原则:

function showClick() {
  var clicks = 0
  return function(e) {
    clicks++
    console.log("click "+clicks+" at "+[e.clientX,e.clientY])
    return clicks
  }
}

document.getElementById("b1").onclick=showClick() 
document.getElementById("b2").onclick=showClick()
Run Code Online (Sandbox Code Playgroud)
<button id="b1">Record my Clicks</button> <!--only stores click history of b1, disregarding b2-->

<button id="b2">Record MY Clicks</button> <!--only stores click history of b2, disregarding b1-->
Run Code Online (Sandbox Code Playgroud)

我可以看到,每次触发事件时,"点击"的值都会被更新和存储(可能是在事件处理函数返回?),但只是单击了相应的按钮.这些值是如何存储的,为什么不在两个事件处理程序之间共享它们?如果我希望在两个按钮之间共享"点击"的值,我是否需要在两者范围之外分配一个变量?

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

Google Charts:ChartWrapper和Formatters(NumberFormat)

如何使用ChartWrapper和格式化程序在线/条形图上的工具提示中添加后缀?这是ChartWrapper的代码

function drawChartb() {

    var wrapper = new google.visualization.ChartWrapper({
    chartType: 'LineChart',
    dataTable: [['Person', 'Score'], [1, .50], [2, .25]],
    options: {'legend': 'bottom', 'colors': ['#D70005'], 'chartArea': {left: 40, top: 10, width: 450}, 'vAxis': {format: '#,###%', 'viewWindow': {max: 1.05, min: .2}}, 'pointSize': 6},
    containerId: 'chart_div'
    });

    wrapper.draw();
}
Run Code Online (Sandbox Code Playgroud)

这就是我在不使用chartwrapper的情况下完成的.

// set tooltip as percentage
var formatter = new google.visualization.NumberFormat({
pattern: '#%', 
fractionDigits: 2
});
formatter.format(data, 1);
Run Code Online (Sandbox Code Playgroud)

谢谢

charts google-visualization google-chartwrapper

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