【问题标题】:How can I use (this).getName() like a string?如何像字符串一样使用 (this).getName()?
【发布时间】:2014-03-07 12:01:59
【问题描述】:

我正在尝试使用(this).getName();,而不是'e3000',我必须在(this).getName(); 周围使用'',而不是'e3000',就像它知道的那样。 如何将(this).getName(); 与''而不是'e3000'一起使用?

data: JSON.stringify([{ 'e3000': {'name': (this).getName(), 'x': (this).getPosition().x, 'y': (this).getPosition().y, 'plan': '1'}}])

【问题讨论】:

    标签: ajax json post http-post


    【解决方案1】:
    data: JSON.stringify([{'"' + (this).getName() + '"': {'name': (this).getName(), 'x': (this).getPosition().x, 'y': (this).getPosition().y, 'plan': '1'}}])
    

    【讨论】:

    • 如果我正确理解了你的问题,它应该可以解决问题:)
    • Sunden 我收到此错误:SyntaxError: missing : after property id
    猜你喜欢
    • 1970-01-01
    • 2019-08-05
    • 1970-01-01
    • 1970-01-01
    • 2011-04-24
    • 1970-01-01
    • 1970-01-01
    • 2020-02-17
    • 1970-01-01
    相关资源
    最近更新 更多