为什么跟老师的代码(3-6)一致会有这个提示呢?

来源:3-8 更近一步 - reactive

同步MU

2020-10-04

Type ‘{ count: number; increase: () => void; double: ComputedRef; }’ is not assignable to type ‘DataProps’.
Types of property ‘double’ are incompatible.
Type ‘ComputedRef’ is not assignable to type ‘number’.

const data: DataProps = reactive({
  count: 0,
  increase: () => { data.count++ },
  double: computed(() => data.count * 2 ),
})
写回答

3回答

张轩

2020-10-06

同学你好 我觉得是不能版本对 reactive 的定义文件有不同,请问你本地是 vue 的什么版本(具体一点,可以看一下 node_modules/vue 里面的 package.json 文件)? 或者你把代码上传 gitee 或者 github,我本地帮你看一下

0
4
张轩
回复
慕尼黑5110603
同学你好 我们的课4月份要升级一次 会有新的文档提供的 谢谢关注
2022-03-08
共4条回复

张轩

2020-10-04

同学请给我看下你的 interface 是怎么写的欧

0
2
MrDan
回复
同步MU
解决了吗,我的也会
2021-06-18
共2条回复

慕莱坞0998854

2020-10-04

老师的代码没有ComputedRef吧?你是不是抄错了?你的DataProps是怎么写的?

0
1
同步MU
鼠标放上去有提示,但不影响程序正常运行
2020-10-05
共1条回复

Vue3 + TS 仿知乎专栏企业级项目

带你完成前后端分离复杂项目,率先掌握 vue3 造轮子技能

3074 学习 · 2253 问题

查看课程