简体   繁体   English

jQuery存储类型未定义

[英]jQuery Storage Type undefined

I used a jQuery storage to store data. 我使用jQuery存储来存储数据。

oStore = jQuery.sap.storage(jQuery.sap.storage.Type.local);
oStore.put("id", rep);

but I am getting this error: 但我收到这个错误:

Cannot read property 'Type' of undefined 无法读取未定义的属性“类型”

Can you please help? 你能帮忙吗?

The reason, why jQuery.sap.storage is not defined, is that the module has not yet been loaded (and thus not globally accessible). 为什么没有定义jQuery.sap.storage的原因是该模块尚未加载(因此不能全局访问)。 Whenever you're using jQuery APIs, make sure to resolve its dependency first, and then use the resolved parameter name instead of accessing APIs globally as mentioned in the documentation : 每当您使用jQuery API时,请确保首先解析其依赖关系,然后使用已解析的参数名称,而不是如文档中所述全局访问API:

Use only local variables inside the AMD factory function, do not access the content of other modules via their global names, not even for such fundamental stuff like jQuery or sap.ui.Device . 在AMD工厂函数中只使用局部变量,不要通过它们的全局名称访问其他模块的内容,即使是像jQuerysap.ui.Device这样的基本内容sap.ui.Device You can't be sure that the modules are already loaded and the namespace is available. 您无法确定模块是否已加载且命名空间是否可用。

Example: 例:

sap.ui.define([
  "jquery.sap.storage",
  // ...
], function(jQuery /*...*/) {
  "use strict";
  const storageType = jQuery.sap.storage.Type.local;
  const storage = jQuery.sap.storage(storageType);
  // ...
});

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM