2016-03-26 14 views
0

Merhaba, İlk Uygulamamı oluşturmaya ve Web sitem için yayımlamaya çalışıyorum. Ben End'deyim, ama Uygulama sorunsuz çalışmayacak. Eski Soruğumda, bir GoBack düğmesi nasıl oluşturulur, Örnek ile bir Yanıt aldım. Örnekte, GoBack düğmesiyle, Uygulamaya başka Sayfalar eklemeye devam ettim. İlk 2-3 Kez, eğer bir sayfadan geri dönersem, düzgün bir şekilde gider, 4 ve sonraki zamanlar için, o zaman devam eder. Birisi Hataları veya başka bir şey için Kodu kontrol edebilirsiniz. Sayfalar Web görünümüne dayanmaktadır. .Uygulama 2-3 kez sonra Lags Geziler

"yöntem Windows.UI.ApplicationSettings.SettingsPane.getForCurrentView kullanımdan kaldırıldı SettingsPane kaldırılmıştır ve tüm platformlarda çalışmayabilir fazla bilgi için,:

Ben Visual Studio bu hataları alıyorum. . bkz: MSDN eval kodu (2) (1,7) "

" CSP14312: güvensiz-eval Sunucu Tanımlı Politikasında ' ': satır içi komut dosyası Kaynak: Kaynak direktifi' script src ms-appx' ihlal bloke edilecek: "

tüm platformlar için, Windows 10 kullanılamaz

Default.js

(function() { 
"use strict"; 

var activation = Windows.ApplicationModel.Activation; 
var app = WinJS.Application; 
var nav = WinJS.Navigation; 
var sched = WinJS.Utilities.Scheduler; 
var ui = WinJS.UI; 

var ViewManagement = Windows.UI.ViewManagement; 
var ApplicationViewWindowingMode = ViewManagement.ApplicationViewWindowingMode; 
var ApplicationView = ViewManagement.ApplicationView; 

app.onactivated = function (args) { 
    if (args.detail.kind === activation.ActivationKind.launch) { 
     if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) { 
      var currentview = Windows.UI.Core.SystemNavigationManager.getForCurrentView(); 
      currentview.appViewBackButtonVisibility = Windows.UI.Core.AppViewBackButtonVisibility.visible; 
      currentview.onbackrequested = onBackRequested; 
      function onBackRequested(eventArgs) { 
       if (WinJS.Navigation.canGoBack) { 
        WinJS.Navigation.back(1).done(function (successInformation) { 
         /*this is the success function*/ 
        }, function (error) { 
         /*this is the error function*/ 
        }); 
       } 
      } 
     } else { 
      // TODO: This application was suspended and then terminated. 
      // To create a smooth user experience, restore application state here so that it looks like the app never stopped running. 
     } 

     nav.history = app.sessionState.history || {}; 
     nav.history.current.initialPlaceholder = true; 

     // Optimize the load of the application and while the splash screen is shown, execute high priority scheduled work. 
     ui.disableAnimations(); 
     var p = ui.processAll().then(function() { 
      return nav.navigate(nav.location || Application.navigator.home, nav.state); 
     }).then(function() { 
      return sched.requestDrain(sched.Priority.aboveNormal + 1); 
     }).then(function() { 
      ui.enableAnimations(); 
     }); 

     args.setPromise(WinJS.UI.processAll()); 
     ApplicationView.preferredLaunchWindowingMode = ApplicationViewWindowingMode.fullScreen; 
    } 
}; 

app.oncheckpoint = function (args) { 
    // TODO: This application is about to be suspended. Save any state that needs to persist across suspensions here. 
    // You might use the WinJS.Application.sessionState object, which is automatically saved and restored across suspension. 
    // If you need to complete an asynchronous operation before your application is suspended, call args.setPromise(). 
    app.sessionState.history = nav.history; 
}; 

app.start(); 
})(); 

Navigator.js

(function() { 
"use strict"; 

var nav = WinJS.Navigation; 

WinJS.Namespace.define("Application", { 
    PageControlNavigator: WinJS.Class.define(
     // Define the constructor function for the PageControlNavigator. 
     function PageControlNavigator(element, options) { 
      this._element = element || document.createElement("div"); 
      this._element.appendChild(this._createPageElement()); 

      this.home = options.home; 

      this._eventHandlerRemover = []; 

      var that = this; 
      function addRemovableEventListener(e, eventName, handler, capture) { 
       e.addEventListener(eventName, handler, capture); 
       that._eventHandlerRemover.push(function() { 
        e.removeEventListener(eventName, handler); 
       }); 
      }; 

      addRemovableEventListener(nav, 'navigating', this._navigating.bind(this), false); 
      addRemovableEventListener(nav, 'navigated', this._navigated.bind(this), false); 

      window.onresize = this._resized.bind(this); 

      Application.navigator = this; 
     }, { 
      home: "", 
      /// <field domElement="true" /> 
      _element: null, 
      _lastNavigationPromise: WinJS.Promise.as(), 
      _lastViewstate: 0, 

      // This is the currently loaded Page object. 
      pageControl: { 
       get: function() { return this.pageElement && this.pageElement.winControl; } 
      }, 

      // This is the root element of the current page. 
      pageElement: { 
       get: function() { return this._element.firstElementChild; } 
      }, 

      // This function disposes the page navigator and its contents. 
      dispose: function() { 
       if (this._disposed) { 
        return; 
       } 

       this._disposed = true; 
       WinJS.Utilities.disposeSubTree(this._element); 
       for (var i = 0; i < this._eventHandlerRemover.length; i++) { 
        this._eventHandlerRemover[i](); 
       } 
       this._eventHandlerRemover = null; 
      }, 

      // Creates a container for a new page to be loaded into. 
      _createPageElement: function() { 
       var element = document.createElement("div"); 
       element.setAttribute("dir", window.getComputedStyle(this._element, null).direction); 
       element.style.position = "absolute"; 
       element.style.visibility = "hidden"; 
       element.style.width = "100%"; 
       element.style.height = "100%"; 
       return element; 
      }, 

      // Retrieves a list of animation elements for the current page. 
      // If the page does not define a list, animate the entire page. 
      _getAnimationElements: function() { 
       if (this.pageControl && this.pageControl.getAnimationElements) { 
        return this.pageControl.getAnimationElements(); 
       } 
       return this.pageElement; 
      }, 

      _navigated: function() { 
       this.pageElement.style.visibility = ""; 
       WinJS.UI.Animation.enterPage(this._getAnimationElements()).done(); 
      }, 

      // Responds to navigation by adding new pages to the DOM. 
      _navigating: function (args) { 
       var newElement = this._createPageElement(); 
       this._element.appendChild(newElement); 

       this._lastNavigationPromise.cancel(); 

       var that = this; 

       function cleanup() { 
        if (that._element.childElementCount > 1) { 
         var oldElement = that._element.firstElementChild; 
         // Cleanup and remove previous element 
         if (oldElement.winControl) { 
          if (oldElement.winControl.unload) { 
           oldElement.winControl.unload(); 
          } 
          oldElement.winControl.dispose(); 
         } 
         oldElement.parentNode.removeChild(oldElement); 
         oldElement.innerText = ""; 
        } 
       } 

       this._lastNavigationPromise = WinJS.Promise.as().then(function() { 
        return WinJS.UI.Pages.render(args.detail.location, newElement, args.detail.state); 
       }).then(cleanup, cleanup); 

       args.detail.setPromise(this._lastNavigationPromise); 
      }, 

      // Responds to resize events and call the updateLayout function 
      // on the currently loaded page. 
      _resized: function (args) { 
       if (this.pageControl && this.pageControl.updateLayout) { 
        this.pageControl.updateLayout.call(this.pageControl, this.pageElement); 
       } 
      }, 
     } 
    ) 
}); 
})(); 

cevap

İlgili konular