【发布时间】:2021-01-15 17:56:45
【问题描述】:
我在我的 svelte-typescript 项目中使用 clickOutside 指令,当我将自定义事件分配给相关元素时出现此错误
Type '{ class: string; onclick_outside: () => boolean; }' is not assignable to type 'HTMLProps<HTMLDivElement>'.
Property 'onclick_outside' does not exist on type 'HTMLProps<HTMLDivElement>'
这是我的代码的 sn-p
{#if profileToolbar}
<div
transition:fly={{ y: -20, duration: 300 }}
use:clickOutside={profileToolbarContainer}
on:click_outside={() => (profileToolbar = !profileToolbar)}
class="origin-top-right absolute right-0 mt-2 w-48 rounded-md
shadow-lg z-10 shadow-md">
这是我当前使用的 clickOutside 指令https://svelte.dev/repl/0ace7a508bd843b798ae599940a91783?version=3.16.7
我是打字稿的新手,所以我真的不知道从哪里开始我的谷歌搜索,有人知道如何解决这个问题吗?感谢您的帮助
【问题讨论】:
标签: javascript typescript typescript-typings svelte svelte-3