javascript覆盖类变量

时间:2020-10-16 01:52:58

标签: javascript frappe

我有一个带有变量的类,我想通过外部文件中的另一个函数更改变量值

类代码

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');

1 个答案:

答案 0 :(得分:0)

Notification类实例设置为frappe.frappe_toolbar.notifications。您可以使用它来覆盖属性。

frappe.frappe_toolbar.notifications.$dropdown = $('.Header').find('.dropdown-item-notifications');