如何解决无法从React App中的CSS文件访问我的公用文件夹
./src/index.css (./node_modules/css-loader/dist/cjs.js??ref--5-oneOf-4-1!./node_modules/postcss-loader/src??postcss!./src/index.css)
Error: Can't resolve '/assets/fonts/PlantinMTProRg.woff' in 'C:\Users\User\Desktop\NewPage\webpage\src'
如您所见,我正在尝试从位于src文件夹中的index.css调用一种字体。
我将其称为:
@font-face {
font-family: 'PlantinMTPro';
src: local('plantin_mt_pro'),url(/assets/fonts/PlantinMTProRg.woff) format('truetype');
}
但是到目前为止还没有运气。图片有相同的问题。
有什么想法吗?
谢谢!
解决方法
在index.html中,必须从公共目录链接index.css
for (i in seq_len(n)[nrows < nr]) {
xi <- vlist[[i]]
if (nrows[i] > 0L && (nr%%nrows[i] == 0L)) {
xi <- unclass(xi)
fixed <- TRUE
for (j in seq_along(xi)) {
xi1 <- xi[[j]]
if (is.vector(xi1) || is.factor(xi1))
xi[[j]] <- rep(xi1,length.out = nr)
else if (is.character(xi1) && inherits(xi1,"AsIs"))
xi[[j]] <- structure(rep(xi1,length.out = nr),class = class(xi1))
else if (inherits(xi1,"Date") || inherits(xi1,"POSIXct"))
xi[[j]] <- rep(xi1,length.out = nr)
else {
fixed <- FALSE
break
}
}
if (fixed) {
vlist[[i]] <- xi
next
}
}
stop(gettextf("arguments imply differing number of rows: %s",paste(unique(nrows),collapse = ",")),domain = NA)
}
从那里,您需要找出正确的URL才能到达您所说的src文件中的字体系列。
<link rel="stylesheet" href="%DIR%/NewPage/webpage/src/index.css">
此外,我注意到您使用的是truetype格式。仅在导入.ttf文件时使用。在这种情况下,请使用@font-face {
font-family: 'PlantinMTPro';
src: local('plantin_mt_pro'),url(/assets/fonts/PlantinMTProRg.woff) format('woff');
}
。
如果您要支持多种浏览器,则可能需要在此处添加一些更改
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。