【问题标题】:knockout pass JSON param to click event淘汰赛将 JSON 参数传递给点击事件
【发布时间】:2021-03-06 00:46:14
【问题描述】:

我有以下html:

<a href="javascript:void(0)" data-bind="click: update.bind($data, '{ "label": "dwsqa" }')">Yes / No</a>

和js:

self.update = function (config) {
    console.log(config);
};

我有错误:

Uncaught Error: Unable to parse bindings.
Message: SyntaxError: Invalid or unexpected token;
Bindings value: click: update.bind($data, '{ 

这里有什么问题?我该如何解决这个问题?

【问题讨论】:

    标签: knockout.js


    【解决方案1】:

    确保您的 json 具有单行结构且引号正确。

    【讨论】:

      猜你喜欢
      • 2015-02-24
      • 2020-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多