【问题标题】:NativeScript floating hintNativeScript 浮动提示
【发布时间】:2016-11-15 10:44:03
【问题描述】:

我在 nativescript 中创建了一个表单,我希望我的字段有浮动提示,就像 TextInputLayout 一样,我发现这个插件 nativescript-textinputlayout 在技术上完全符合我的要求,但问题是我使用 angular 2使用我的应用程序,我似乎无法弄清楚如何使用 angular 2 的插件。有人可以帮忙吗?除了使用插件实现浮动提示之外,我也对其他解决方案持开放态度

【问题讨论】:

  • 这就是您需要的插件。我没有确切的 sn-p 来使用该插件,但这里有一个使用带有角度 github.com/bradmartin/nativescript-drawingpad/blob/master/… 的 ui 插件的示例,因此您需要的是 registerElement()
  • 感谢您的帮助!
  • @OmarEssam 你能发布一些 sn-p 你是怎么做到的吗?我遇到了一些错误。谢谢

标签: android nativescript android-textinputlayout angular2-nativescript


【解决方案1】:

nativescript-textinputlayout 是一个“香草”NativeScript 组件。为了在 Angular 中使用它,您需要使用 element registry API 将其注册为 Angular 模板的有效标签。

示例:

my-component.component.ts

import { registerElement } from "nativescript-angular/element-registry";

registerElement("TextInputLayout", () => require("nativescript-textinputlayout").TextInputLayout);

@Component({
   selector: "my-component",
   moduleId: module.id,
   templateUrl: "./my-component.component.html"
})
export class MyComponent {}

my-component.component.html

<StackLayout>
   <TextInputLayout hint="my hint" hintAnimationEnabled="true">
      <TextField text="my content"></TextField>
   </TextInputLayout>
</StackLayout>

【讨论】:

    【解决方案2】:

    @rajlaxmi_jagdale 最近的更新好像有问题...

    从 mode_modules/nativescript-textinputlayout/textInputLayout.d.ts 中删除以下行

    export const iconFontProperty: 属性;

    它会起作用的!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-05
      • 2020-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多