javascript - Webpack custom attribute md-icon-src is not converted when packaging
阿神
阿神 2017-05-18 10:58:30
0
1
695

There is a component in my Vue project

  <md-bottom-bar-item v-for="tab in tabs"
    :id="tab.id"
    md-icon-src="../assets/icon/ic_home_black_48px.svg"
    :md-active='tab.active'>{{ tab.title }}
  </md-bottom-bar-item>

But when npm run build, md-icon-src is not converted into a packaged path.
But check that webpack.base.conf.js supports svg

  {
    test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
    loader: 'url-loader',
    options: {
      limit: 10000,
      name: utils.assetsPath('img/[name].[hash:7].[ext]')
    }
  },

Is this because md-icon-src is a custom attribute? How to solve it.

阿神
阿神

闭关修行中......

reply all(1)
phpcn_u1582

You also need to set transformToRequire for vue-loader in webpack, and the md-icon-src attribute of the md-bottom-bar-item element must be converted to require.

See: http://vue-loader.vuejs.org/e...

Or attend this lecture: /l/15..., 35% off limited time offer.

Another idea is to require the svg file in the script to give the component instance data, and then bind the data to md-icon-src.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!