-
Notifications
You must be signed in to change notification settings - Fork 340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
最新的dva项目要怎么配置 svg-sprite-loader 以支持antd-mobile的 Icon 组件使用? #345
Comments
@paranoidjk 有空帮忙看下。 |
@luajoy 请检查并给出下面两个信息
|
|
@luajoy roadhog 版本也要升级。see antd-mobile@Icon 这里我稍后也在 readme 里面注明一下 |
非常感谢,困扰一天的问题终于解决了:
const path = require('path'); export default { 然后在源码中使用Icon,<Icon type={require('../assets/scan.svg')} />,终于显示了,错误也没了! 最新的 dva-cli 创建的项目,默认的roadhog版本是0.5.2,希望改为最新版本。非常感谢! |
参照 road-hog 的方式,配置不成功。
由于dva项目中没有.roadhogrc.js文件,自行创建.roadhogrc.js文件并设置内容为:
const path = require('path');
const svgSpriteDirs = [
require.resolve('antd-mobile').replace(/warn.js$/, ''), // antd-mobile 内置svg
path.resolve(__dirname, 'src/assets'), // 业务代码本地私有 svg 存放目录
];
export default {
// ...
svgSpriteLoaderDirs: svgSpriteDirs,
//...
}
然后添加语句 <Icon type={require('../assets/scan.svg')} />
但是运行时,浏览器js报错:Icon props.type is invalid, have you set svg-sprite-loader correctly?
The text was updated successfully, but these errors were encountered: