是否有任何节点<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
上的
答案 0 :(得分:14)
是否有任何节点@ types / *模块或任何可以为InputEvent提供类型定义的东西?
是的,您可以使用@types/dom-inputevent。
答案 1 :(得分:3)
是否有任何节点@ types / *模块或任何可以为InputEvent提供类型定义的东西?
@types/dom-inputevent
安装它。 dom.d.ts
,因为这里没有广泛支持/最终确定:https://developer.mozilla.org/en-US/docs/Web/API/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)
)