7-6 category1Id和category2Id为什么报错啊
来源:7-6 电子书管理增加分类选择

forever十
2021-07-17
Property 'category1Id' does not exist on type '{}'.
209 | const handleModalOk = () => {
210 | modalLoading.value = true;
> 211 | ebook.value.category1Id = categoryIds.value[0];
| ^^^^^^^^^^^
212 | ebook.value.category2Id = categoryIds.value[1];
213 | axios.post("/ebook/save", ebook.value).then((response) => {
214 | modalLoading.value = false;
ERROR in src/views/admin/admin-ebook.vue:212:29
TS2339: Property 'category2Id' does not exist on type '{}'.
210 | modalLoading.value = true;
211 | ebook.value.category1Id = categoryIds.value[0];
> 212 | ebook.value.category2Id = categoryIds.value[1];
| ^^^^^^^^^^^
213 | axios.post("/ebook/save", ebook.value).then((response) => {
214 | modalLoading.value = false;
215 | const data = response.data; //data = commonResp
ERROR in src/views/admin/admin-ebook.vue:236:50
TS2339: Property 'category1Id' does not exist on type '{}'.
234 | modalVisible.value = true;
235 | ebook.value = Tool.copy(record);
> 236 | categoryIds.value = [ebook.value.category1Id, ebook.value.category2Id]
| ^^^^^^^^^^^
237 | };
238 | // ebook.value.category1Id = categoryIds.value[0];
239 | // ebook.value.category2Id = categoryIds.value[1];
ERROR in src/views/admin/admin-ebook.vue:236:75
TS2339: Property 'category2Id' does not exist on type '{}'.
234 | modalVisible.value = true;
235 | ebook.value = Tool.copy(record);
> 236 | categoryIds.value = [ebook.value.category1Id, ebook.value.category2Id]
| ^^^^^^^^^^^
237 | };
238 | // ebook.value.category1Id = categoryIds.value[0];
239 | // ebook.value.category2Id = categoryIds.value[1];
run页面的category1Id和category2Id都报错
写回答
1回答
-
forever十
提问者
2021-07-17
// -------- 表单 --------- /** * 数组,[100, 101]对应:前端开发 / Vue */ const categoryIds = ref(); const ebook = ref({});
这里要把
const ebook = ref({});
改为
const ebook = ref();
812022-03-20
相似问题