【发布时间】:2019-06-06 11:59:33
【问题描述】:
IonButton --- 颜色
我目前正在开发一个必须为我的实习创建的应用程序。为此,我在 React 中工作,我只是导入 Ionic 组件来简化任务。
当我构建一些 Ionic 组件时,我的问题来自 JSX 部分。我创建了 Ionic Card 组件、IonButton 组件等......并且一切正常!但是当我只想修改其中一个按钮的颜色时,它不起作用......
我试过这样做:。 但它不起作用。我也尝试创建一个名为 style 的变量,它是一个具有适当性的对象(颜色:“成功)但它也不起作用。
import React from 'react';
import * as _ from 'lodash';
import './Delivery.css';
import { IonText, IonButton } from '@ionic/react';
import { IonCard } from '@ionic/react';
import { IonContent, IonFooter, IonToolbar, IonTitle, IonRow } from '@ionic/react';
import Map from './Map';
import Phone from './Phone';
const Delivery = ({delivery}) => {
const Command_ID = delivery.order_id;
const Delivery_Slot = delivery.endtime.substr(0, 2);
//{delivery.endtime.substr(0, 2)-1}h-{delivery.endtime.substr(0, 2)}h
const post_metas = delivery.post_meta;
const firstname = post_metas[_.findIndex(post_metas, post_meta => {return post_meta.meta_key === '_shipping_first_name'})].meta_value;
const lastName = post_metas[_.findIndex(post_metas, post_meta => {return post_meta.meta_key === '_shipping_last_name'})].meta_value;
const PostalCode = post_metas[_.findIndex(post_metas, post_meta => {return post_meta.meta_key === '_shipping_postcode'})].meta_value;
const adressPerso = post_metas[_.findIndex(post_metas, post_meta => {return post_meta.meta_key === '_shipping_address_1'})].meta_value;
const city = post_metas[_.findIndex(post_metas, post_meta => {return post_meta.meta_key === '_shipping_city'})].meta_value;
const Tel = post_metas[_.findIndex(post_metas, post_meta => {return post_meta.meta_key === '_billing_phone'})].meta_value;
return (
<IonCard>
<div>
<span style={{ color: 'grey' }}>#{Command_ID} - </span><span style={{ color: 'purple'}}>{Delivery_Slot - 1}h-{Delivery_Slot}h</span>
<div>
<strong>{firstname} {lastName}</strong>
<p></p>
<div>
{adressPerso},{PostalCode},{city}
<IonFooter >
<div>
<IonToolbar transparent >
<IonRow>
<IonButton expand="block">
<Phone phone={Tel} />
</IonButton>
<IonButton expand="block">
<Map MapData={adressPerso} />
</IonButton>
<IonButton color="success">
Terminé
</IonButton>
</IonRow>
</IonToolbar>
</div>
</IonFooter>
</div>
</div>
</div>
</IonCard>
);
/*
return (
<div>App2</div>
);
*/
};
export default Delivery;
【问题讨论】:
-
根据文档颜色是一个属性。试试
<ion-button color="success"> Termine </ion-button>看看是否可行 -
对不起,我已经在我的问题中写下了你的答案,但它被替换为“。” ^^ 它也不起作用,我很惊讶,因为它是 IonButton 对象的专有物
-
你为什么用
<ion-button>而不是<IonButton>? -
试试
<IonButton color="success">...</IonButton>@JulienTxerriakGuillou -
我刚刚尝试了这种通常适应 Angular 的表单。这两种形状都不起作用...
标签: reactjs ionic-framework colors components jsx