简体   繁体   English

是否可以添加自定义输入并使用ScriptTag调用第三方API?

[英]Is it possible to add a custom input and call 3rd party API with the ScriptTag?

The Shopify documentation on the ScriptTag is really vague. ScriptTag上的Shopify 文档确实含糊不清。 For example, it says that the following endpoint will create a new script tag: 例如,它说以下端点将创建一个新的脚本标记:

POST /admin/script_tags.json
{
  "script_tag": {
    "event": "onload",
    "src": "https://djavaskripped.org/fancy.js"
  }
}

But what should I put into that src js file? 但是我应该在那个src js文件中放什么呢? Is it possible to add a custom input into a chosen online store page? 是否可以在所选的在线商店页面上添加自定义输入? If so, how? 如果是这样,怎么办? I couldn't find any documentation or even a post about this. 我找不到任何文档,甚至找不到与此相关的帖子。

A script tag is loaded by Shopify and executes after onload. 一个脚本标签由Shopify加载,并在onload之后执行。 What can you do with that? 你能怎么办? Well, as an App developer, you may very well want some Javascript code to run, without you having to have the merchant install that code. 嗯,作为应用程序开发人员,您可能非常希望运行一些Javascript代码,而不必让商家安装该代码。 Merchants are often not technical. 商人通常不是技术人员。

So you write Javascript in your fancy.js file that adds value to the merchant. 因此,您可以在fancy.js文件中编写Javascript,从而为商家增加价值。 Your JS could render a new DOM element like an input and deal with changes to it. 您的JS可以呈现一个新的DOM元素(如输入)并处理对其的更改。 Sure. 当然。 Why not. 为什么不。 Dare to dream. 敢于梦想。 Dream big! 远大的梦想!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM