运行测试时,.wxs文件错误
Closed this issue · 1 comments
gxbsst commented
错误信息
Error: 编译 .wxml 文件错误:common/wxs/utils.wxs:168:26:Unexpected token.
经排查时,是wxs文件:(value || '').replace 导致的
function snakeCase(value, separator) {
separator = separator || '_';
return (value || '').replace(getRegExp('([A-Z])', 'g'), function() {
return separator + arguments[1].toLowerCase();
});
}测试组件代码如下
测试代码
const id = simulate.load(path.resolve('src/pages/home/index'), {
less: true,
compiler: 'official',
rootPath: path.resolve('src/'),
});
const comp = simulate.render(id, {
loading: true,
info: { item: { price: 111 } }
});组件
<wxs src="../../common/wxs/utils.wxs" module="utils" />
<view class="page-home-wrap w-full">utils.wxs
function snakeCase(value, separator) {
separator = separator || '_';
return (value || '').replace(getRegExp('([A-Z])', 'g'), function() {
return separator + arguments[1].toLowerCase();
});
}以上, 请问有什么解决办法吗?
JuneAndGreen commented
旧的编译器有 bug,可以更新一下到 1.3.3 版本,里面的 miniprogram-compiler 依赖会制定用最新的版本。