首页 > 解决方案 > 标识符“eye”已被声明

问题描述

我正在使用 ionic+react 开发应用程序。在登录页面密码字段中使用眼睛和眼睛离开图标时,它已经被声明错误。破折号“视线”似乎有问题。如果包含破折号的任何其他图标,同样的问题。

./src/pages/Login.tsx
SyntaxError: D:\project\src\pages\Login.tsx: Identifier 'eye' has already been declared (12:28)

  10 | import React, { createContext, useState, useEffect } from "react";
  11 | import { IonGrid, IonRow, IonCol } from "@ionic/react";
> 12 | import { personCircle, eye, eye-off } from "ionicons/icons";
     |                             ^
  13 | import { useHistory } from "react-router-dom";
  14 | import {
  15 |   IonItem,

代码页

<IonRow>
            <IonCol>
              <IonItem>
                <IonLabel position="floating"> Password</IonLabel>
                <IonInput
                  type={passwordShown ? "text" : "password"}
                  value={password}
                  onIonChange={(e) => setPassword(e.detail.value!)}
                ></IonInput>
                <IonIcon icon={passwordShown ? eye : eye-off} onClick={togglePasswordVisiblity} slot="end"></IonIcon>
              </IonItem>
            </IonCol>
          </IonRow>

请建议

标签: reactjsionic-framework

解决方案


推荐阅读