引用vant的icon组件导致文件不可编译,原因是icon本地路径不识别,解决方案如下:
找到node_modules中vant下的dist或lib,找到里面的 wxs/utils.wxs
代码:
var bem = require('./bem.wxs').bem;
var memoize = require('./memoize.wxs').memoize;
var addUnit = require('./add-unit.wxs').addUnit;
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),
memoize: memoize,
addUnit: addUnit,
isSrc: isSrc
};
这样本地路径就可用了
<van-cell-group class="link-box">
<van-cell
is-link
title="更改授权手机号"
link-type="navigateTo"
url="/pages/account/changeTel"
icon="/images/changetel_icon.png"
/>
<van-cell
is-link
title="注销账户"
link-type="navigateTo"
url="/pages/account/logout"
icon="/images/logout_icon.png"
/>
</van-cell-group>