What is the origin and purpose of the variable $data in KnockoutJS?

前端 未结 3 806
一向
一向 2020-12-24 04:31

In the KnockoutJS tutorials I stumbled upon the following code example that contains an unexplainable variable $data.

The View (html):



        
3条回答
  •  星月不相逢
    2020-12-24 05:12

    i made it work

    .selected {
        color:red;
    }
    
    
      var viewModel = { // Data folders: ['Inbox', 'Archive', 'Sent', 'Spam'], selectedFolder: ko.observable('Inbox'), // Behaviours selectFolder: function (folder) { this.selectedFolder(folder); } }; window.mailViewModel = viewModel; ko.applyBindings(viewModel);

      please take a look at http://jsfiddle.net/bowen31337/48RDd/

    提交回复
    热议问题