2017-04-06 120 views
0
const { module } = this.props; 

return(
    <div className="Card"> 
     <Link to=`/${module}/detail`></Link> 
    </div> 
) 

上述語法有什麼問題?我得到錯誤JSX value should be either an expression or a quoted JSX textes6 jsx語法錯誤使用「`」

+0

請注意,您所引用的內容無效JavaScript(即使正確,就像在Reagan Cuthbertson的回答中一樣)。將來也可以用[tag:react-jsx]標記這些問題。 – Amadan

回答

1

在JSX中使用JavaScript時,您需要將它包裝在花括號中。您在Link組件的to屬性值中使用的模板文字需要大括號。

return (
    <div className="Card"> 
     <Link to={`/${module}/detail`}></Link> 
    </div> 
);