首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >文本字段中的Nativescript

文本字段中的Nativescript
EN

Stack Overflow用户
提问于 2019-03-04 11:07:15
回答 2查看 3.5K关注 0票数 2

我试图在Nativescript角项目的文本框中获取图标。当我试图完成这件事时,它会被放置在场外,或者至少看起来是这样的。我看过一些代码示例(示例),但是当我自己尝试它时,它是行不通的。

代码语言:javascript
运行
复制
<GridLayout rows="auto, auto, auto, auto, auto" class="container" loaded="onLoaded()">
  <app-eon-colors-top></app-eon-colors-top>
  <StackLayout row="1" class="logo">
    <Image src="res://live_logo"></Image>
  </StackLayout>
  <Stacklayout row="2" class="form">
    <StackLayout>
      <TextField #userName hint="Användarnamn" class="field" [text]="userInput.username" required [isEnabled]="!(processing$ | async)" keyboardType="email" autocapitalizationType="none" autocorrect="false" (textChange)="setUsername($event)" (focus)="focusUserName($event)"
        (returnPress)="focusPassword()"></TextField>
    </StackLayout>
    <GridLayout columns="auto, *, auto">
      <Label col="0" class="icon fa-regular" [text]="lockIcon"></Label>
      <TextField col="1" #password hint="Lösenord" class="field" [text]="userInput.password" required [isEnabled]="!(processing$ | async)" secure="true" autocapitalizationType="none" autocorrect="false" (textChange)="setPassword($event)" (focus)="focusPassword($event)"
        (returnPress)="submit()">
      </TextField>
      <Label col="2" class="icon fa-regular" [text]="activePasswordShowHideIcon" ios:style="padding-bottom: 35" (tap)="showHidePassword()"></Label>
    </GridLayout>
    <Label class="error-msg" textWrap="true" *ngIf="(errors$ | async)" [text]="errorTxt"></Label>
    <Button class="login-button" text="LOGGA IN" [isEnabled]="!(processing$ | async)" (tap)="submit()"></Button>
  </Stacklayout>
  <ActivityIndicator rowSpan="5" color="#23a1b0" [busy]="(processing$ | async)" width="100" height="100" class="activity-indicator"></ActivityIndicator>
</GridLayout>

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-03-04 13:10:24

您必须删除TextField附带的默认背景/边框,并将边框应用到父容器,使其看起来像TextField的一部分。

示例

代码语言:javascript
运行
复制
    <StackLayout class="form">
        <GridLayout class="m-10 input-border" columns="*,auto">
            <TextField col="0" class="input"></TextField>
            <Label col="1" class="h3" text="" verticalAlignment="center"></Label>
        </GridLayout>
    </StackLayout>

操场样本

票数 2
EN

Stack Overflow用户

发布于 2021-06-16 20:05:02

最后,我将TextField的边距设置为负值。不确定这是不是正确的方法。但这似乎是我想要的。

代码语言:javascript
运行
复制
<StackLayout orientation="horizontal">
    <TextField text="Test"
        (tap)="onCollectionDateTap($event)"
        style="width: 200; margin-right:-15;"></TextField>
    <Label class="fa" text="&#xf06e;" ></Label>
</StackLayout>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54981976

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档