We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用vue3,没有使用ts的情况,有触发事件,输出的e对象也是正确的,但是修改fill无效。
<script setup> const rect = new Rect({ x: 100, y: 100, width: 200, height: 200, fill: '#32cd79', stroke: 'black', strokeWidth: 2, draggable: true }) leafer.add(rect) function onEnter(e) { console.log(e); e.fill = '#42dd89' } function onLeave(e) { e.fill = '#32cd79' } rect.on(PointerEvent.ENTER, onEnter) rect.on(PointerEvent.LEAVE, onLeave) </script>
这样使用是没有问题的:
<script setup lang="ts"> import { Leafer, Rect, PointerEvent } from 'leafer-ui' const leafer = new Leafer({ view: window }) const rect = new Rect({ x: 100, y: 100, width: 200, height: 200, fill: '#32cd79', stroke: 'black', strokeWidth: 2, draggable: true }) leafer.add(rect) function onEnter(e: PointerEvent) { console.log(e); (e.current as Rect).fill = '#42dd89' } function onLeave(e: PointerEvent) { (e.current as Rect).fill = '#32cd79' } rect.on(PointerEvent.ENTER, onEnter) rect.on(PointerEvent.LEAVE, onLeave) </script>
The text was updated successfully, but these errors were encountered:
只把类型删掉就行,上面这段代码把 import 语句和事件里的 current 都删掉了
这样改应该就没有问题
<script setup> import { Leafer, Rect, PointerEvent } from 'leafer-ui' const leafer = new Leafer({ view: window }) const rect = new Rect({ x: 100, y: 100, width: 200, height: 200, fill: '#32cd79', stroke: 'black', strokeWidth: 2, draggable: true }) leafer.add(rect) function onEnter(e) { console.log(e); e.current.fill = '#42dd89' } function onLeave(e) { e.current.fill = '#32cd79' } rect.on(PointerEvent.ENTER, onEnter) rect.on(PointerEvent.LEAVE, onLeave) </script>
Sorry, something went wrong.
只把类型删掉就行,上面这段代码把 import 语句和事件里的 current 都删掉了 这样改应该就没有问题 <script setup> import { Leafer, Rect, PointerEvent } from 'leafer-ui' const leafer = new Leafer({ view: window }) const rect = new Rect({ x: 100, y: 100, width: 200, height: 200, fill: '#32cd79', stroke: 'black', strokeWidth: 2, draggable: true }) leafer.add(rect) function onEnter(e) { console.log(e); e.current.fill = '#42dd89' } function onLeave(e) { e.current.fill = '#32cd79' } rect.on(PointerEvent.ENTER, onEnter) rect.on(PointerEvent.LEAVE, onLeave) </script>
感谢,已经解决了。看文档的时候没有留意到还有current这个属性
No branches or pull requests
使用vue3,没有使用ts的情况,有触发事件,输出的e对象也是正确的,但是修改fill无效。
这样使用是没有问题的:
The text was updated successfully, but these errors were encountered: