【发布时间】:2021-10-10 14:51:36
【问题描述】:
注意我正在使用@vueuse/core 库来获取以下示例的一些值,但我相信这个问题的库知识是没有实际意义的。
我有以下三重观察者:
// Reactive Mouse Positionining
const { x, y } = useMouse()
// Detect if the Mouse has been pressed:
const { pressed } = useMousePressed({
target: celestiaSkyViewerRoot,
touch: true
})
watch([pressed, x, y], ([newPressed, newX, newY], [prevPressed, prevX, prevY]) => {
if (showConstellations.value) {
if (!newPressed && newX !== prevX) {
activeConstellation.value = getActiveConstellation(newX, newY)
}
}
dragging.value = pressed.value
if (newPressed && newX !== prevX) {
azimuthalOffset.value -= (newX - prevX) / 6
}
})
但是,我发现出现以下 Typescript 错误:
对于newX,相关线路:activeConstellation.value = getActiveConstellation(newX, newY)
Argument of type 'number | boolean' is not assignable to parameter of type 'number'. Type 'boolean' is not assignable to type 'number'.
对于newX,相关线路:azimuthalOffset.value -= (newX - prevX) / 6
The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
但是,Vetur 仅显示newY 的问题,与以下行有关:azimuthalOffset.value -= (newX - prevX) / 6:
The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
有人知道可能的解决方案吗?从本质上讲,这些错误正在停止重新加载我的开发服务器......而且它正在成为一个令人沮丧的开发瓶颈......
【问题讨论】:
标签: javascript typescript vuejs3 vue-composition-api vetur