您好,我创建了一个随机报价生成器 Windows 应用商店应用程序,所有报价都很好,我遇到的唯一问题是如何让报价每天更改,而不是每次从第一次开始时都更改页面到应用程序的第二页,反之亦然。任何帮助或正确方向的观点将不胜感激。
下面是引用将在 JavaScript 中显示的页面的代码副本:
// 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("/pages/page2/page2.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) {
// TODO: Initialize the page here.
client.getTable("quotes").read().then(function (q) {
{
var randomquote = Math.round(Math.random() * (q.length));
function printquote() {
output.innerHTML += "<div>" + (q[randomquote].body + "</div>");
}
printquote();
}
}, function (err) { debugger; });
},
unload: function () {
// TODO: Respond to navigations away from this page.
},
updateLayout: function (element) {
/// <param name="element" domElement="true" />
// TODO: Respond to changes in layout.
}
});
})();
最佳答案
如评论中所述,在服务器而不是客户端更改引号更有意义。
创建一个基于当前日期返返回价的服务器页面。您可以通过多种方式实现它,但一个直接的实现是在每个报价首次创建时添加一个日期,然后仅在该日期提供服务。
关于javascript - 每日随机报价生成器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23050227/