我有一个非常奇怪的问题。我可能在这里做一些非常愚蠢的事情,但没有意识到。我正在使用 vue.js 1。我有一个组件,它是一个启动模式,它发出 4 个自定义事件。对于其中的每一个,我都有一个在父级上注册的侦听器。非常奇怪的问题是,每当我注册第 4 个监听器时,第 4 个监听器注册的事件都不会发出!
// on parent component template...
<fbu-create-maker-commission-modal
v-ref:new-commission-modal
modal-id="addSpCommissionModal"
:show-modal="showCreationModal"
v-on:hiding-modal="onHidingModal"
v-on:sp-commission-created="onCreatingNewSpCommission"
v-on:sp-commission-updated="onUpdatingSpecialCommission"
v-on:sp-commission-remove="onDeletingSpecialCommission"
:modal-template-data="templateData"
:mode="modalLaunchMode"
:object-to-edit="toEditObject"
></fbu-create-maker-commission-modal>
// child component code where the events are emitted from
editCommission() {
let config = Object.assign({}, this.modalTemplateData.httpConfig.updateSpecialCommission, { body: this.form.formData })
this.$http(config).then(response => {
console.log(response);
if(this.isVueResourceResponseValid(response)) {
this.$emit('sp-commission-updated', response.body.data.updatedCommission);
this.handleModalClose();
}
}).catch(errorResponse => {
console.log(errorResponse);
if(errorResponse.status == 422) {
for(errorKey in errorResponse.body) {
this.$set(`form.errors.${errorKey}`, errorResponse.body[errorKey]);
}
}
});
},
deleteCommission() {
let config = Object.assign({}, this.modalTemplateData.httpConfig.deleteSpecialCommission, { body: this.form.formData })
// console.log(config);
this.$http(config).then(response => {
// console.log(response);
if(this.isVueResourceResponseValid(response)) {
console.log('here');
this.$emit('sp-commission-remove', response.body.data.deletedSpecialCommission);
this.handleModalClose();
}
}).catch(errorResponse => {
});
},
createCommission() {
let config = Object.assign({}, this.modalTemplateData.httpConfig.createSpecialCommission, { body: this.form.formData })
this.$http(config).then(response => {
if(this.isVueResourceResponseValid(response)) {
this.$emit('sp-commission-created', response.body.data.newCommission);
this.handleModalClose();
}
}).catch(errorResponse => {
if(errorResponse.status == 422) {
for(errorKey in errorResponse.body) {
this.$set(`form.errors.${errorKey}`, errorResponse.body[errorKey]);
}
}
});
},
如果我在父级上为此注册了一个监听器,则sp-commission-remove事件不会被发出,就像这样 -v-on:sp-commission-remove="onDeletingSpecialCommission"
如果我删除这个监听器,或者甚至更改客户事件名称的任何字符,事件会发出很好!
在 Vue1 中可以发出多少个侦听器/事件是否有限制?
它快把我逼疯了。有人可以指导我正确的方向吗?