Vant Weapp 有赞小程序UI库 ICON 组件的本地图标路径支持
dist或lib 组件文件夹下面的: wxs/utils.wxs
var bem = require('./bem.wxs').bem; var memoize = require('./memoize.wxs').memoize; function isSrc(url) { return url.indexOf('http') === 0 || url.indexOf('data:image') === 0 || url.indexOf('//') === 0; } module.exports = { bem: memoize(bem), isSrc: isSrc, memoize: memoize };
第5行,return后面加
url.indexOf(".") === 0 || url.indexOf("/") === 0 ||
即:
var bem = require('./bem.wxs').bem; var memoize = require('./memoize.wxs').memoize; function isSrc(url) { return url.indexOf(".") === 0 || url.indexOf("/") === 0 || url.indexOf('http') === 0 || url.indexOf('data:image') === 0 || url.indexOf('//') === 0; } module.exports = { bem: memoize(bem), isSrc: isSrc, memoize: memoize };
icon组件的路径即可使用本地路径了。
<van-icon name="/assets/images/alert.svg" />