Comments (6)
如果不是 ant design
带的图标,需要自己改源代码实现
https://github.com/sendya/ant-design-pro-vue/blob/master/src/components/menu/index.js#L60
from ant-design-vue-pro.
你好,路由自定义图标功能已提供支持。
具体可以看 master
分支的 /src/config/router.config.js
中 dashboard
的 icon
设定。
或者查看 路由配置说明 router/README.md
from ant-design-vue-pro.
路由如何支持自定义的icon?
import { Icon } from 'ant-design-vue'
// iconfont
import './assets/less/style.less'
const IconFont = Icon.createFromIconfontCN({
scriptUrl: '//at.alicdn.com/t/font_730323_xk8qmej2ayl.js' // 在 iconfont.cn 上生成
})
Vue.component('icon-font', IconFont)「
然后调整下 menu.js
的 renderIcon
方法
renderIcon (icon) {
if (icon === 'none' || icon === undefined) {
return null
}
if(icon.startsWith('icon-')) {
return (
<icon-font type={icon} />
)
}
const props = {}
typeof (icon) === 'object' ? props.component = icon : props.type = icon
return (
<Icon {... { props } }/>
)
}
就可以使用 iconfont
图标,也可以使用自带的图标
from ant-design-vue-pro.
路由如何支持自定义的icon?
import { Icon } from 'ant-design-vue' // iconfont import './assets/less/style.less' const IconFont = Icon.createFromIconfontCN({ scriptUrl: '//at.alicdn.com/t/font_730323_xk8qmej2ayl.js' // 在 iconfont.cn 上生成 }) Vue.component('icon-font', IconFont)「
然后调整下
menu.js
的renderIcon
方法renderIcon (icon) { if (icon === 'none' || icon === undefined) { return null } if(icon.startsWith('icon-')) { return ( <icon-font type={icon} /> ) } const props = {} typeof (icon) === 'object' ? props.component = icon : props.type = icon return ( <Icon {... { props } }/> ) }
就可以使用
iconfont
图标,也可以使用自带的图标
能不能解释详细一点?自定义的icon是什么文件?需要在main.js引入吗?menu.js是哪个路径下的?是不是需要自己修改源代码呀?
from ant-design-vue-pro.
路由如何支持自定义的icon?
import { Icon } from 'ant-design-vue' // iconfont import './assets/less/style.less' const IconFont = Icon.createFromIconfontCN({ scriptUrl: '//at.alicdn.com/t/font_730323_xk8qmej2ayl.js' // 在 iconfont.cn 上生成 }) Vue.component('icon-font', IconFont)「
然后调整下
menu.js
的renderIcon
方法renderIcon (icon) { if (icon === 'none' || icon === undefined) { return null } if(icon.startsWith('icon-')) { return ( <icon-font type={icon} /> ) } const props = {} typeof (icon) === 'object' ? props.component = icon : props.type = icon return ( <Icon {... { props } }/> ) }
就可以使用
iconfont
图标,也可以使用自带的图标能不能解释详细一点?自定义的icon是什么文件?需要在
main.js
引入吗?menu.js是哪个路径下的?是不是需要自己修改源代码呀?
太久了,源码应该变动了,之前这个项目应该是有一个menu.js。
现在的话,当前layout
是引用ant-desing-vue/pro-layout
,定位到@ant-design-vue/pro-layout/es/components/RouteMenu/BaseMenu.js
var renderIcon = function renderIcon(h, icon) {
if (icon === undefined || icon === 'none' || icon === null) {
return null;
}
var props = {};
typeof icon === 'object' ? props.component = icon : props.type = icon;
return h(Icon, {
props: props
});
};
所以,现在的话,你可能需要去改这里的代码,建议你直接到ant-design-vue
这个项目搜下issue或者提个issue咨询一下,看是pro-layout这里的BaseMenu的逻辑可否调整为可以支持iconfont的形式,或是询问下是否有其他更好的方案,
from ant-design-vue-pro.
不要再老 issue 反复提问,有问题请开新 issue
from ant-design-vue-pro.
Related Issues (20)
- 大佬项目还维护吗 隔壁的elemen-plus垃圾的要死 如果还维护我们就用你们的啦 HOT 1
- 我想知道在使用表格嵌套时,如何让子表格得到父表格的record或者index?
- 能否同时支持mock + devServer proxy? HOT 1
- 访问内部静态网页
- npm i 报错
- 求教下:批量引入组件的实现方式
- 什么时候适配 ant design vue 4.0 ? HOT 1
- 屏蔽mock之后,登陆成功无法跳转
- pro-layout 怎么自定义菜单栏内容呀?
- 代理后端服务器地址不生效
- 点击一级菜单时,能否默认选中其路由配置的redirect的二级菜单,并打开相应的页面
- 部署完 微信上打开 登录失败 但是pc端正常
- yarnpkg run serve后chunk-vendors.js文件几十兆
- run serve报错 HOT 3
- 解答:为什么热更新不可以
- 项目加载会请求https://gw.alipayobjects.com,如何才能将者些请求屏蔽,或者去掉?离线项目已经不需要了
- 登录Login请求中then不执行
- 为什么 暗黑模式禁用了??? HOT 1
- 界面滚动bug
- yarn报错[email protected]: The engine "node" is incompatible with this module. Expected version ">=18". Got "16.14.2" HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ant-design-vue-pro.