我正在尝试在启动时为我的UWP-JS应用程序创建设置值。 我正在关注此文档 。
这是我目前得到的:
(function () { "use strict" //Initialization var localSettings = Windows.Storage.ApplicationData.current.localSettings; // Save value localSettings.Values["exampleSetting"] = "example"; // Retrieve value $('p').text(localSettings.Values["exampleSetting"]); })();当我启动应用程序时,它进入“中断模式”,在给定代码的第7行中出现以下异常:
0x800a138f - JavaScript运行时错误:无法设置未定义或空引用的属性“exampleSetting”
我究竟做错了什么?
I am trying to create a Settings Value for my UWP-JS App on Startup. I am following this Documentation.
Here is what I've currently got:
(function () { "use strict" //Initialization var localSettings = Windows.Storage.ApplicationData.current.localSettings; // Save value localSettings.Values["exampleSetting"] = "example"; // Retrieve value $('p').text(localSettings.Values["exampleSetting"]); })();When I start the Application it enters 'Break Mode' with the following exception in line 7 of the given code:
0x800a138f - JavaScript runtime error: Unable to set property 'exampleSetting' of undefined or null reference
What am I doing wrong?
最满意答案
您缺少current属性,在您提到的示例中也提到了该属性。 所以你的电话应该是:
(function () { "use strict" //Initialization var localSettings = Windows.Storage.ApplicationData.current.localSettings; // Save value localSettings.values["exampleSetting"] = "example"; // Retrieve value $('p').text(localSettings.values["exampleSetting"]); })();编辑: Windows.Storage.ApplicationData之后的属性和方法名称需要以小写字母开头。
You are missing the current property, which is also mentioned in the example you refered to. So your call should be:
(function () { "use strict" //Initialization var localSettings = Windows.Storage.ApplicationData.current.localSettings; // Save value localSettings.values["exampleSetting"] = "example"; // Retrieve value $('p').text(localSettings.values["exampleSetting"]); })();Edit: The properties and method names after Windows.Storage.ApplicationData need to be start with lowercase.
更多推荐
发布评论