Giter VIP home page Giter VIP logo

Comments (6)

sendya avatar sendya commented on May 17, 2024

如果不是 ant design 带的图标,需要自己改源代码实现
https://github.com/sendya/ant-design-pro-vue/blob/master/src/components/menu/index.js#L60

from ant-design-vue-pro.

sendya avatar sendya commented on May 17, 2024

你好,路由自定义图标功能已提供支持。

具体可以看 master 分支的 /src/config/router.config.jsdashboardicon 设定。
或者查看 路由配置说明 router/README.md

from ant-design-vue-pro.

jianchengwang avatar jianchengwang commented on May 17, 2024

路由如何支持自定义的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.jsrenderIcon 方法

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.

chf-gh avatar chf-gh commented on May 17, 2024

路由如何支持自定义的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.jsrenderIcon 方法

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.

jianchengwang avatar jianchengwang commented on May 17, 2024

路由如何支持自定义的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.jsrenderIcon 方法

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.

sendya avatar sendya commented on May 17, 2024

不要再老 issue 反复提问,有问题请开新 issue

from ant-design-vue-pro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.