2017-01-05 4 views
1

成分が反応します。どのように反応成分にCSSを含める必要がありますか?読み込みスタイルがために、私は、次の例を以下

は私がlogin.cssファイルの作成を試みた:

#components-form-demo-normal-login .login-form { 
    max-width: 300px; 
} 
#components-form-demo-normal-login .login-form-forgot { 
    float: right; 
} 
#components-form-demo-normal-login .login-form-button { 
    width: 100%; 
} 

をそして1 className(送信ボタン)に変更:

import styles from './login.css';  
<Button type="primary" htmlType="submit" className={styles.login-form-button}> 
    Log in 
</Button> 

が、WebPACKのは、私に語った:

42:76 error 'form' is not defined no-undef 
42:81 error 'button' is not defined no-undef 

方法をスタイルシートを含めることはできますか?

答えて

2

あなたもコンポーネントを宣言しました。あなたが必要なもの は、このような文字列としてクラス名を指定することです:

import './login.css';  
<Button id="your-id" type="primary" htmlType="submit" className="your-class-name"> 
    Log in 
</Button> 

ボタンがコンポーネントではない場合は何がしたいことを使用する場合、それは代わりに「ボタン」

import './login.css';  
<button id="your-id" type="primary" htmlType="submit" className="your-class-name"> 
    Log in 
</button> 

する必要があります

var styles = { 
    someStyle: { ..props} 
} 

<button id="your-id" type="primary" htmlType="submit" style={styles.someStyle}> 
    Log in 
</button> 
+0

ありがとう、それは動作しますが、「スタイル」は定義されていますが、決して使用されていないことを教えていますが、どうすればそれをきれいにすることができますか? – FacundoGFlores

+1

あなたの宣言を次のように変更してください: 'import './login.css';' 私の答えは受け入れてください。ありがとう –

関連する問題