想知道在vue方法中传递参数和在this.localData中使用数据或属性引用之间的最佳实践是什么?
有一个这样的模板
<div @click="close_tab"/>
<span>
{{ tabInstance.count }}
</span>
</div> close_tab(id, isCurrentTab) {
if (isCurrentTab) {
this[REMOVE_CURRENT_TAB]();
this.$router.push({ name: 'home' });
} else {
this[REMOVE_TAB](id);
}
},
// or below
close_tab() {
if (this.isCurrentTab) {
this[REMOVE_CURRENT_TAB]();
this.$router.push({ name: 'home' });
} else {
this[REMOVE_TAB](this.tab.id);
}
},发布于 2020-10-16 17:12:18
这取决于您的使用环境。如果您不想将close_tab与this.tab.id和this.isCurrentTab之外的其他值一起使用,那么您不应该以参数样式编写您的方法。
https://stackoverflow.com/questions/64386102
复制相似问题