gpt4 book ai didi

javascript - 从 extJS 4 迁移到 extJS 5 : property undefined

转载 作者:行者123 更新时间:2023-11-30 05:35:27 26 4
gpt4 key购买 nike

在尝试将我的应用程序从 ExtJS4 更新到 ExtJS5 时,我遇到了这个错误:

Uncaught TypeError: Cannot read property 'get' of undefined 

使用以下代码:

Ext.onReady(function () {
Ext.require([
'Ext.util.Cookies'
]);
top.Dictionary.setDictionary(fr_FR);

var formUserNameValue = "";
if (Ext.util.Cookies.get('userName')) { <<<< the error occurs here
formUserNameValue = Ext.util.Cookies.get('userName');
}

还有 index.html 页面:

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<title>Login</title>

<!-- Importation ExtJS -->
<script type="text/javascript" src="../../ext-5.0.0/ext-debug.js"></script>
<link rel="stylesheet" href="../../ext-5.0.0/packages/ext-theme-neptune/build/resources/ext-theme-neptune-all.css"/>

<script type="text/javascript" src="app.js"></script>

<!-- Importation des dictionnaires -->
<script type="text/javascript" src="dictionary/fr_FR.js"></script>
<script type="text/javascript" src="dictionary/en_EN.js"></script>

你知道那可能来自哪里吗?

最佳答案

Ext.require 是异步的,即它向服务器发送请求并立即返回。您有两个选择,第一个,如果可行则更好:

  1. Ext.require 移到 onReady 之前
  2. 使用Ext.syncRequire

关于javascript - 从 extJS 4 迁移到 extJS 5 : property undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24084768/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com