标签的属性中包含json字符串数据时解析有误
bigmeow opened this issue · comments
const wxml = require("@vivaxy/wxml");
function dealwith(inputCode) {
const parsed = wxml.parse(inputCode);
wxml.traverse(parsed, function visitor(node) {
console.log(node);
});
return wxml.serialize(parsed);
}
const test1 = dealwith(`
<view data-route="{{ {'name': 'user-info'} }}"></view>
<view class="icon-box" data-route='{\"name\": \"user-info\"}' ></view>
`);
console.log("test1:", test1);
实际输出结果:
正确<view data-route="{{ {'name': 'user-info'} }}"></view>
不正确<view class="icon-box" data-route="{"name": "user-info"}"></view>
期望输出结果:
<view data-route="{{ {'name': 'user-info'} }}"></view>
<view class="icon-box" data-route='{\"name\": \"user-info\"}' ></view>
从结果看,转义符被干掉了,单引号会被转成双引号,希望这块不被处理
2.0.3 已修复