Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么我的工作是’;是否在我的JSS样式表中声明了@font-face未加载?_Javascript_Reactjs_Jss - Fatal编程技术网

Javascript 为什么我的工作是’;是否在我的JSS样式表中声明了@font-face未加载?

Javascript 为什么我的工作是’;是否在我的JSS样式表中声明了@font-face未加载?,javascript,reactjs,jss,Javascript,Reactjs,Jss,为什么我的@font-face规则没有加载woff?我的createStyleSheet(): 在我的React组件之外设置: // ./jss.css import jss from 'jss'; import vendorPrefixer from 'jss-vendor-prefixer'; /** * Reformat classNames * mechanism and format the classes as we see fit. * * @method create

为什么我的@font-face规则没有加载woff?我的
createStyleSheet()

在我的React组件之外设置:

// ./jss.css
import jss from 'jss';
import vendorPrefixer from 'jss-vendor-prefixer';


/**
 * Reformat classNames
 * mechanism and format the classes as we see fit.
 *
 * @method createGenerateId
 * @return {String}         Formatted class name
 */
const createGenerateId = () => (rule) => {
    return rule.key.toString().replace(/\./, '_DOT_');
};


export default jss
    .use(vendorPrefixer())
    .setup({ createGenerateId });

然后在里面:

import jss from './jss';
woff的URL是好的。如果我点击该URL,浏览器将下载.woff文件。当我检查
this.sheet
实例时,我看到了其中的规则

我的CSS类格式正确:

.font\uu Whitney--423{
字体系列:Whitney BlackItal ProGkCy TDB、Whitney BlackItal ProGkCy TDA、Fallback、Courier;
字体大小:“正常”;
}
我尝试过的任何东西都不会加载woff文件并在屏幕上显示样式文本


我在这里遗漏了什么?

工作表本身是否正确连接-其他主题信息是否被理解?文件的路径匹配吗?是否应该是相对的–
url(./--
)?您也可以尝试将格式声明添加到url中,如下所示:
src:“url(/fonts/woff/Whitney BlackItal ProGkCy TD.woff)格式('woff')”,
。亲爱的@BrandonDurham,您找到解决方法了吗?
componentDidMount() {
        this.sheet = jss.createStyleSheet({
            '@font-face': {
                fontFamily: 'Whitney-BlackItal-ProGkCy-TDA',
                src: 'url(/fonts/woff/Whitney-BlackItal-ProGkCy-TD.woff)',
                fontWeight: 'normal',
                fontStyle: 'normal'
            }
        }).attach();
    }