2017-09-29 45 views
0

我想補充的風格是這樣的:流星類型錯誤:需要(...)addStyles不是一個函數

import './landing.css'; 

import { someClass } from "./landing.css"; 

在反應成分,收到此錯誤:

TypeError: require(...).addStyles is not a function

我使用的最後一個流星1.5.2.1

/imports/ui/pages/Landing.jsx 在陣營組成:

import React, { Component } from 'react'; 
import { Grid, Row, Col } from 'react-bootstrap'; 
import './landing.css' 
// import { someClass } from "./landing.css"; 

export default class Landing extends Component { 

    constructor(props){ 
    super(props); 
    } 

    render() { 
    return (
     <Grid fluid id="landing"> 
      <Row className="show-grid"> 
       <Col xs={12} md={12}> 
        <h1 className="someClass"> 
         Landing Page 
        </h1> 
       </Col> 
      </Row> 
     </Grid> 
    ); 
    } 
} 

/imports/ui/pages/landing.css 在./landing.css:

.someClass { 
    color: red 
} 

我是否需要一些額外的包?

+1

顯示您正在使用的整個代碼(包含文件路徑)。 – Styx

回答

0

你不能這樣導入:「從」./landing.css「導入{someClass};」 您可以使用此代碼 import './landing.css'; 「進口」後,包括你的CSS文件,你應該寫相對路徑的css文件

+0

是的,我知道我可以請看看我的例子。我在兩種情況下都遇到了錯誤。你有流星流星1.5.2.1嗎? –

0

確保您「/imports/ui/pages/Landing.jsx」未進口到「lib」或「兩個」或「服務器」?當我嘗試執行SSR並將文件加載到「lib」目錄(可由服務器和客戶端訪問)時,我只看到錯誤發生。

相關問題