简体   繁体   English

玉语法错误如何发送json到js吗?

[英]jade syntax error how to send json to js ?

a(href="#" id="pickndroppoints" data-pickuppoints="[{"Id":"HGHD","Time":"2014-01-28 21:00:00.0","Name":"Beach Road"}]")

jade compile give systax error Unexpected identifier 玉编译给systax错误意外的标识符

Is there a way to do this ? 有没有办法做到这一点 ? I need to send json and based on it certain event is triggered using js 我需要发送json并基于它使用js触发某些事件

your attribute value for data-pickuppoints is breaking at. 您的data-pickuppoints属性值已突破。

data-pickuppoints="[{"Id":"HGHD","Time":"2014-01-28 21:00:00.0","Name":"Beach Road"}]"

as you have double quotes inside the json data. 因为您在json数据中有双引号。 make it like 使它像

data-pickuppoints='[{"Id":"HGHD","Time":"2014-01-28 21:00:00.0","Name":"Beach Road"}]'

or escape the double quotes 或转义双引号

I would say, as jade parameter are regular javascript, that you only have to use single quotes so the value wont break : 我会说,因为jade参数是常规javascript,您只需要使用单引号,这样值就不会中断:

a(href="#" id="pickndroppoints" data-pickuppoints='[{"Id":"HGHD","Time":"2014-01-28 21:00:00.0","Name":"Beach Road"}]')

But I am not on my computer so I cant test. 但是我不在电脑上,所以我无法测试。

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

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