Using Chrome Console to Access Knockout ViewModel with RequireJS

后端 未结 3 1486
长情又很酷
长情又很酷 2021-01-31 05:07

How do I access the KnockOut ViewModel variables in the Chrome console now that I am using RequireJS?

Before using RequireJS, I followed a namespacing pattern, hiding ev

3条回答
  •  你的背包
    2021-01-31 05:23

    Require is all about not having globals:

    require(["knockout"],function(ko){ window.ko=ko;}); 
    

    is introducing globals again

    You can use this in the console:

    require("knockout").dataFor($0);
    require("knockout").contextFor($0);
    

提交回复
热议问题