TypeScript是否具有InputEvent的类型定义?

时间:2018-04-08 04:05:05

标签: typescript

是否有任何节点<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:*snip*.Renderers;assembly=*snip*" x:Class="*snip*.MainPage"> <ContentPage.Resources> <ResourceDictionary> <DataTemplate x:Key="template1"> <local:PostViewCell> <StackLayout BackgroundColor="White" Margin="10, 10, 10, 10" Padding="10, 10, 10, 10"> . . . </StackLayout> </local:PostViewCell> </DataTemplate> <DataTemplate x:Key="template2"> <local:PostViewCell> <StackLayout BackgroundColor="White" Margin="10, 10, 10, 10" Padding="10, 10, 10, 10"> . . . </StackLayout> </local:PostViewCell> </DataTemplate> <local:PostTemplateSelector x:Key="templateSelector" Template1="{StaticResource template1}" Template2="{StaticResource template2}" ></local:PostTemplateSelector> </ResourceDictionary> </ContentPage.Resources> <ContentPage.Content> <StackLayout> <local:PostListView x:Name="PostListView" ItemTemplate="{StaticResource templateSelector}"/> </StackLayout> </ContentPage.Content> 模块或任何可以为@types/*提供类型定义的内容?

InputEvent上的

Read here for more info

3 个答案:

答案 0 :(得分:14)

  

是否有任何节点@ types / *模块或任何可以为InputEvent提供类型定义的东西?

是的,您可以使用@types/dom-inputevent

答案 1 :(得分:3)

  

是否有任何节点@ types / *模块或任何可以为InputEvent提供类型定义的东西?

答案 2 :(得分:2)

InputEvent@types/dom-inputevent中的定义不正确。正如其他人所指出的,这是因为在发布此内容时,它仍处于试验阶段。

相反,请考虑使用KeyboardEvent

inputElement.addEventListener('keyup', (e: KeyboardEvent) => 
    const input = (event.target as HTMLInputElement).value
    console.log(input, e.key)
)