ViewState处理程序updateLayout方法在default.js中处理时永远不会被命中

ViewState handler updateLayout method never get hit when handled within default.js

本文关键字:处理 永远 时永 js updateLayout 程序 方法 default ViewState      更新时间:2023-09-26

我从一个空白模板开始,在那里我得到了default.htm和default.js。我想在应用程序从完全模式转到捕捉或填充模式等时处理事件。我添加了updateLayout方法,但当我在这里添加断点时,它永远不会被命中。现成方法的断点正在被击中。我在这里做错了什么?

// For an introduction to the Page Control template, see the following documentation:  
// http://go.microsoft.com/fwlink/?LinkId=232511  
(function () {  
    "use strict";  
    WinJS.UI.Pages.define("default.html", {  
        // This function is called whenever a user navigates to this page. It  
        // populates the page elements with the app's data.  
        ready: function (element, options) {  
        },
        unload: function () {
            // TODO: Respond to navigations away from this page.
        },
        updateLayout: function (element, viewState, lastViewState) {
        }
    });

})();

这有点令人困惑,但updateLayout实际上并不是一个事件处理程序。

从其他模板启动时包含的导航框架处理不同的事件(window.onresize),并调用updateLayout函数(如果存在)。例如,如果使用导航模板创建一个新项目,并检查navigator.js,您将看到onresize事件的处理位置,以及updateLayout函数的调用位置。

如果从Blank模板开始,则此功能不可用,因此您需要(a)处理onresize事件,(b)将navigator.js添加到项目中,或者(c)使用不同的项目模板。