简体   繁体   English

电子邮件的 AMP 列表无法加载示例 json

[英]AMP-list for email fail to load sample json

I'm new to AMP and I'm a creative designer so my knowledge of front-end backend is limited.我是 AMP 新手,我是一名创意设计师,所以我对前端后端的了解有限。 I trying to do an AMP email which load info from json and display it in the email.我试图做一个 AMP 电子邮件,它从 json 加载信息并将其显示在电子邮件中。

I'm using sample AMP-list component script fromhttps://amp.dev/documentation/components/amp-list/?format=email , everything work fine but when I replace the json link with my sample file it didn't work https://wegoexperience.com/dest.json我正在使用来自https://amp.dev/documentation/components/amp-list/?format=email 的示例 AMP-list 组件脚本,一切正常,但是当我用我的示例文件替换 json 链接时,它没有工作https://wegoexperience.com/dest.json

Anyone can advice why?任何人都可以建议为什么? Thanks!谢谢!

Answer: it's all about CORS, read here: https://amp.dev/documentation/guides-and-tutorials/learn/cors-in-email/答:这都是关于 CORS,请在此处阅读: https : //amp.dev/documentation/guides-and-tutorials/learn/cors-in-email/

In the sandbox on https://amp.dev/ you won't be able to check your own JSON.https://amp.dev/上的沙箱中,您将无法检查自己的 JSON。

If you have an Apache server, then create(in the folder where the JSON file is located) .htaccess file and write the following code there:如果您有 Apache 服务器,则创建(在 JSON 文件所在的文件夹中) .htaccess文件并在那里编写以下代码:

Header add Access-Control-Allow-Origin: "*"
Header add AMP-Access-Control-Allow-Source-Origin: "youaddress@youdomain.com"
Header add Access-Control-Expose-Headers: "AMP-Access-Control-Allow-Source-Origin"

After that, AMP-list should work if you test locally or on your server.之后,如果您在本地或服务器上进行测试,AMP-list 应该可以工作。

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

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