amis icon indicating copy to clipboard operation
amis copied to clipboard

部分正则规则无法识别

Open zhangyucumt opened this issue 6 years ago • 2 comments

情景是这样: 这是前端代码

const schema = {
    "type": "page",
    "body": [
        {
        "type": "form",
        "controls": [
            {
                "type": "service",
                "schemaApi": "get:xxxx`
            }
        ],
    }]
};

后端接口返回的其中一个字段是这样:

{
    "label": "路径",
    "name": "path",
    "type": "text",
    "placeholder": "请填写正确的路径",
    "validationErrors": {"matchRegexp": "请填写正确的路径"},
    "validations": "matchRegexp:/^\/(\w+\/?)+$/"
}

但是返回之后 前端无法正确识别这个正则,也不报错。同样尝试了 /^\// ,/^// 均无法正常工作。 但是换成 类似 /^abc/ 这样的正则就可以正常识别。

zhangyucumt avatar Jul 08 '20 08:07 zhangyucumt

validations: {
  "matchRegexp": "/^\\/(\\w+\\/?)+$/"
}

试试

2betop avatar Jul 08 '20 08:07 2betop

validations: {
  "matchRegexp": "/^\\/(\\w+\\/?)+$/"
}

试试

这个可以!

zhangyucumt avatar Jul 08 '20 09:07 zhangyucumt