GithubHelp home page GithubHelp logo

Comments (3)

Forever17s avatar Forever17s commented on May 17, 2024 1

@XboxYan 你好,我的项目在作为npm包导出后,在使用icon时那个svg读取不到。使用一个vue项目通过npm的方式引你这个xy-icon标签发现也是有问题的。

image

所以想跟题主一样,将svg放到服务端再引入,结果发现引不进来。请问还有什么好的办法吗

from xy-ui.

XboxYan avatar XboxYan commented on May 17, 2024

image

建议把图标库放在本地,同时注意路径是否正确。

推荐使用其他方式引入组件库。

from xy-ui.

xiaopc avatar xiaopc commented on May 17, 2024

若使用模块打包器并将 xy-ui 作为组件引入,手动修改 node-modules 下的 xy-icon.js

  1. 在最前面加上 import sprite from '../iconfont/icon.svg';

  2. 修改

    this.use.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', `../iconfont/icon.svg#icon-${newValue}`);

    ../iconfont/icon.svg 改为 ${sprite}

暂时没找到兼容浏览器 modules 引入的方法(浏览器下 MIME type 非 javascript 无法加载,而模块打包器不处理 stage 3 动态加载)

from xy-ui.

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.