所以我试图在React应用程序中使用weather-icons。
我下载了package并将其添加到我的解决方案(here)中。
(我使用react-redux-universal-hot-example入门套件)
在Forecast.js容器中,我添加了以下内容:
import React, {Component, PropTypes} from 'react';
import {connect} from 'react-redux';
import {fetchForecast} from 'redux/modules/weatherForecast';
@connect(
state => ({forecast: state.weatherForecast.forecast}),
{fetchForecast}
)
export default class Forecast extends Component {
render() {
return (
<div>
<i className="wi wi-day-sunny"></i>
</div>);
}
}
&#13;
它还没有工作......
我的代码结构:
[src]
|--[containers]
| |--[Forecast]
| |--Forecast.js
|
|--[weather-icons]
|--[css]
|--[font]
|--[less]
|--[sass]
|--[values]
答案 0 :(得分:3)
一种方法是直接导入css文件; (如所述here)
import 'weather-icons/css/weather-icons.css';
注意:路径可以更改。我通过npm安装了weather-icons包,这意味着它在node_modules下。
导入css文件后,您可以像下面一样使用它;
<i className="wi wi-day-lightning"></i>