如何解决javascript覆盖类变量
我有一个带有变量的类,我想通过外部文件中的另一个函数更改变量值
类代码
frappe.ui.Notifications = class Notifications {
constructor() {
frappe.model
.with_doc('Notification Settings',frappe.session.user)
.then(doc => {
this.notifications_settings = doc;
this.make();
});
}
make() {
this.$dropdown = $('.navbar').find('.dropdown-notifications');
this.$dropdown_list = this.$dropdown.find('.notifications-list');
this.$notification_indicator = this.$dropdown.find('.notifications-indicator');
}
};
我要更改变量this.$dropdown
frappe.ui.Notifications.$dropdown = $('.Header').find('.dropdown-item-notifications');
解决方法
Notification类实例设置为frappe.frappe_toolbar.notifications
。您可以使用它来覆盖属性。
frappe.frappe_toolbar.notifications.$dropdown = $('.Header').find('.dropdown-item-notifications');
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。