我有一個簡單的WINJS flipview。有5個圖像從外部json文件加載。所有的圖像立即加載,除了第一個,第二個問題是有一個簡單的命令來自動設置這些旋轉?SimpleFlip查看從json回來的第一張圖片不會立即顯示在winjs中
因此,我們正在使用單頁模型的應用程序。這是一個我想放在一個頁面上旋轉的小促銷滑塊。我已經嘗試了一切,包括只是演示,但第一個項目總是回來undefined。
我什至嘗試刪除第一個圖像,但第一個項目總是回來undefined。我已經花了幾天的時間,沒有太多的運氣。
<div id="promoTemplate" data-win-control="WinJS.Binding.Template" style="display: none" >
<div class="overlaidItemTemplate">
<img class="image" data-win-bind="src: picture" />
<div class="overlay">
<h2 class="ItemTitle" data-win-bind="innerText: title"></h2>
</div>
</div>
</div>
<div id="promoFlipView" class="flipView" data-win-control="WinJS.UI.FlipView" data-win-options="{ itemDataSource: ActivityPromoData.bindingList.dataSource, itemTemplate: select('#promoTemplate') }">
</div>
這被連接到演示的例子flipview數據
////此代碼,所提供之信息「按原樣」而不 擔保////任何種類,明示或暗示,包括但不限於 ////暗含的有關適銷性和/或適用性的擔保,具體涉及 ////特定用途。 //// ////版權所有(c)Microsoft Corporation。保留所有權利
(函數(){ 「使用嚴格的」;
// This is an array that will be used to drive the FlipView in several
// scenarios. The array contains objects with the following attributes:
//
// type - There are two types that are used:
//
// item -
// The type for simple items. It informs the custom
// renderer that their is a title and picture that needs
// to be rendered.
//
// contentsArray -
// This is used for creating a table of contents. It
// informs the renderer that an array of data is present
// for use in constructing the Table of Contents.
//
// title - The title of a photo to be displayed.
//
// picture - The location of the photo to be displayed.
var array = [
{ type: "item", title: "Cliff", picture: "images/Cliff.jpg" },
{ type: "item", title: "Grapes", picture: "images/Grapes.jpg" },
{ type: "item", title: "Rainier", picture: "images/Rainier.jpg" },
{ type: "item", title: "Sunset", picture: "images/Sunset.jpg" },
{ type: "item", title: "Valley", picture: "images/Valley.jpg" }
];
var bindingList = new WinJS.Binding.List(array);
WinJS.Namespace.define("ActivityPromoData", {
bindingList: bindingList,
array: array
});
var e = ActivityPromoData.bindingList.dataSource;
})();
這裏上面的原始問題是第一個圖像錯誤修正:加入這個onready。這工作提供沒有自定義動畫。
var proxyObject;
proxyObject = new WinJS.Binding.as({
itemTemplate: tutorialTemplate,
customAnimations: false
});
tutorialFlipView.winControl.itemTemplate = tutorialTemplate;
是的,圖像是本地的,而不是外部的,所以不要以爲xhr是正確的方法。 – imaginethepoet
如果可能,共享html/js。本地圖像應該沒有問題地加載 – Sushil
顯然,這是一個長期存在的BUG - 它甚至有一個名爲「第一個圖像」的問題。這源於winprocess在使用單頁(導航)模型時似乎不能正確工作的事實。我將發佈我們不得不最終做的工作,並在Professional Win 8 win js書中發現。 – imaginethepoet