Javascript quotation marks issue?
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-19 10:12:43
0
2
656

I don’t know how to express the question. Go directly to code

  xAisdata.push("(u'Chunyang', 9)")
        
  xAisdata.push("(u"Fu'an", 505)")#值中的"和外面的"冲突了。
        
  xAisdata.push("(u'Huwei', 250)")
        
  xAisdata.push("(u'Tainan City', 66926)")
        
  xAisdata.push("(u'Dacang', 868)")
        

The value to be added to the array is the value retrieved from the database. Therefore, changing this value may not be practical. How should I handle this situation? Thanks


{% for k,v in data %}
            xAisdata.push("{{ k | safe}}");
{% endfor %}

{% %} is Django’s template syntax

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(2)
阿神
var str = "(u\"Fu'an\", 505)"; 

console.log(str); 

Use escape characters

If you don’t bring it when you come out of the database

It is recommended to use template string

`(u\"Fu'an\", 505)`
伊谢尔伦

Isn’t it okay to assign that (u"Fu'an", 505), (u'Dacang', 868), etc. to a local variable and then push (the variable)?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template