Debug Knockout js View文件中的变量值

时间:2013-08-18 10:34:02

标签: asp.net-mvc-4 knockout.js

我可以在* .cshtml文件上调试下面提到的代码吗?我使用knockout js作为我的客户端java脚本库。

<div data-bind="ifnot: book()">
        <div>
            <h2>Add New Book</h2>
        </div>
        <div>
            <label for="name">Name</label>
            <input data-bind="value: $root.Name" type="text" title="Name" />
        </div>

        <div>
            <label for="publisher">Publisher</label>
            <input data-bind="value: $root.Publisher" type="text" title="Publisher" />
        </div>

        <div>
            <label for="price">Price</label>
            <input data-bind="value: $root.Price" type="text" title="Price" />
        </div>
        <br />
        <div>
            <button data-bind="click: $root.create">Save</button>
            <button data-bind="click: $root.reset">Reset</button>

        </div>
    </div>

在上面的代码中我需要检查说“book()或$ root.Name等”的值。可以这样做吗?

更新:On Fire bug

enter image description here

2 个答案:

答案 0 :(得分:1)

您需要使用客户端调试。使用开发人员工具栏(在大多数浏览器中使用 F12 打开)或使用Visual Studio Client Script debugging

答案 1 :(得分:0)

在@nemesv链接之后我做了一个关于这个的小R&amp; D.我已经提到了你可以找到DOM元素的KO绑定值的方法。希望这将有助于将来的人。

扩展程序的链接:KnockoutJs Context Debugger

您可以在DOM元素上找到KO值的方法。

enter image description here

相关问题