From a67f0568f0539b0557ed9a0c638e8e5188945ff3 Mon Sep 17 00:00:00 2001 From: wxzhang Date: Thu, 30 Mar 2023 08:52:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(runtime):=20=E6=B7=BB=E5=8A=A0=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E9=9B=B6=E5=AE=BD=E5=BA=A6=E5=8C=B9=E9=85=8D=E7=9A=84?= =?UTF-8?q?=E6=97=A0=E9=99=90=E5=BE=AA=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/runtime/interpolate.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/runtime/interpolate.js b/packages/runtime/interpolate.js index 50ce48f..2724175 100644 --- a/packages/runtime/interpolate.js +++ b/packages/runtime/interpolate.js @@ -105,6 +105,10 @@ function forEachInterpolatedVars(str, replacer, options = {}) { let opts = Object.assign({replaceAll: true },options); varWithPipeRegexp.lastIndex = 0; while ((matched = varWithPipeRegexp.exec(result)) !== null) { + // 这对于避免零宽度匹配的无限循环是必要的 + if (matched.index === varWithPipeRegexp.lastIndex) { + varWithPipeRegexp.lastIndex++; + } const varname = matched[1] || ""; // 解析格式化器和参数 = [,[,[,,...]]] const formatters = parseFormatters(matched[2] || "");