search

Home  >  Q&A  >  body text

javascript - How vue introduces svg files in HTML

On the Internet, you can use the object element, but it reports 404, so the path is definitely correct.

Code:

过去多啦不再A梦过去多啦不再A梦2748 days ago990

reply all(3)I'll reply

  • 三叔

    三叔2017-06-28 09:28:52

    Check this:
    https://stackoverflow.com/que...

    reply
    0
  • PHP中文网

    PHP中文网2017-06-28 09:28:52

    Since the resource is svg, it is best to use the svg tag to reference it, so that you can resize the svg, set the fill color, and a series of svg features.

    How to quote depends on which loader is used:

    html:

        <use xmlns:xlink="http://www.w3.org/1999/xlink" :xlink:href="require('../svg/icon-header.svg')"></use>

    webpack:

        {
            test: /\.svg$/,
            loader: 'svg-sprite?' + JSON.stringify({
                name: '[name]_[hash]',
                prefixize: true
            })
        }

    Loader address: https://github.com/kisenka/svg-sprite-loader
    You can view the API in detail.

    reply
    0
  • typecho

    typecho2017-06-28 09:28:52

    If used as a picture, it can be used directly as a background
    background-image: url('../../../static/icons/site.svg');

    reply
    0
  • Cancelreply