【发布时间】:2020-04-04 15:18:06
【问题描述】:
我是 Vue js 的新手,我正在尝试了解方法中 nextTick 的使用逻辑。所以我有两个这样的组件:
IsTuruIslem.vue
<template>
...
<t-row>
<is-turu-islem-goruntule ref="isTuruIslemGoruntule"
@kaydet="kaydet"
@guncelle="guncelle">
</is-turu-islem-goruntule>
</t-row>
...
</template>
<script>
...
isTuruIslemPopupAc(detay) {
if (!detay) this.$refs.isTuruIslemGoruntule.open();
else {
let guncellenecekDetay = JSON.parse(JSON.stringify(detay));
console.log("Popup:", guncellenecekDetay);
this.$refs.isTuruIslemGoruntule.open({
isUpdate: true,
detay: guncellenecekDetay
});
}
}
...
</script>
IsTuruIslemGoruntule.vue
<template>
...
<t-row>
<t-col :span="20">
<t-select
id="sirket"
ref="sirket"
label="Şirket *"
v-model="detay.sirket"
item-value="id"
item-text="aciklama"
/>
</t-col>
</t-row>
<t-row>
<t-col :span="20">
<t-select
id="cmb_durum"
ref="durum"
label="Durum"
itemText="text"
itemValue="id"
v-model="detay.durumBaseDTO"
:readonly="false"
:clearable="true"
:disabled="false"
/>
</t-col>
....
</template>
<script>
...
methods: {
open: function(options) {
this.isOpen = true;
if (options) {
this.isUpdate = true;
this.detay = JSON.parse(JSON.stringify(options.detay));
} else {
this.detay = {};
}
//this.$nextTick(() => {
this.$refs.durum
.get("/ytts/api/common/durumlar/aktifPasif", null)
.then(data => {})
.catch(err => null);
this.$refs.islem
.get("/ytts/api/tanimYonetimi/isTuruIslem/sorgula/islemListesi")
.then(data => {})
.catch(err => null);
this.$refs.sirket
.get("/ytts/api/tanimYonetimi/isTuruIslem/sorgula/sirketListesi")
.then(data => {})
.catch(err => null);
//});
//console.log("DETAY:", this.detay);
},
...
</script>
我的问题是本示例中的代码无法正常工作,并且在 this.$refs.durum 存在的行中出现“无法读取未定义的属性 'get'”。但是,当我取消注释位于 this.$refs.durum 顶部的 nextTick 方法时,它神奇地起作用了。我真的不明白这种用法。有人可以清楚地向我解释吗?感谢您的关注。
【问题讨论】:
-
伙计,我阅读了该文件,但我的脑海中仍有问题:D
标签: javascript vue.js frontend