gpt4 book ai didi

firefox - ExtJs5 - 覆盖 ext-all-debug.js 中定义的 native 方法

转载 作者:行者123 更新时间:2023-12-02 12:17:42 25 4
gpt4 key购买 nike

假设我想覆盖文件ext-all-debug.js中Sencha提供的 native 代码内的函数。

该函数在 Ext.util.Renderable 类中定义,名称为 cacheRefEls

覆盖应该发生在项目的index.html内,以便将来的版本更容易维护。

<小时/>

我已经尝试过此线程中提出的覆盖解决方案:

Steps to overriding Sencha ExtJS standard component functionality (Ext.tree.Panel & Ext.data.TreeStore as two examples)

<小时/>

我的index.html如下所示:

<html>
...
<script type="text/javascript">
Ext.define('Myapp.view.Renderable', {
override: 'Ext.util.Renderable',
cacheRefEls: function(el) {
console.log("in overider method");
//my adapted version of it
}
});
</script>
...
</html>

不幸的是,通过 Firefox-33 访问 localhost:8080 后,从 Firebug-2-Console-log 中可以看到它仍然存在使用该函数的 native 版本。

我在这里缺少什么?

最佳答案

在 ExtJS 5 中,您需要将这些方法移至 privates 配置。

您应该已经看到错误:

Public method "cacheRefEls" conflicts with private framework method declared by Ext.util.Renderable

您仍然可以重写私有(private)方法。对于您的情况,解决方案是:

Ext.define('Myapp.view.Renderable', {
override: 'Ext.util.Renderable',
privates: {
cacheRefEls: function(el) {
console.log("in overider method");
//my adapted version of it
}
}
});

关于firefox - ExtJs5 - 覆盖 ext-all-debug.js 中定义的 native 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26712839/

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