我正在尝试在我的应用程序中使用 Roboto 字体,但遇到了困难。
I did npm install --save typeface-roboto
并添加了import 'typeface-roboto'
到我的 React 组件。但仍然无法改变我的字体。
我正在尝试这样做:
const React = require('react')
import 'typeface-roboto'
class Example extends React.Component {
render() {
let styles = {
root: {
fontFamily: 'Roboto'
}
}
return (
<div style={styles.root}>
<p>
This text is still not Roboto ?!???!!1
</p>
</div>
)
}
}
module.exports = Example
我错过了什么吗?寻找一种简单的方法来做到这一点,无需任何外部 css 文件..
尝试添加import 'typeface-roboto';
在根文件即index.js 文件中。
就我而言,我将 font-family 添加到 body 元素中,并且它有效。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)