簡體   English   中英

replaceAll function 被標記為...?

[英]replaceAll function is being marked as...?

您看到的代碼在技術上有效。 但是 VS Code 在replaceAll function 下顯示了一個下划線。 我想知道為什么,以及我能做些什么來避免這種情況再次發生。

renderTemplateText(str) {
    var parser = new DOMParser();
    var doc = parser.parseFromString(str, "text/html");
    var xRepeat = doc.querySelectorAll('[x-repeat]');
    var divarray = doc.querySelectorAll('[is^="x-"]');
    var divarraylength = divarray.length;


    for (var i = 0; i < divarraylength; i++) {                                                           
            var dataAttribute = divarray[i].getAttribute('data-link');                                                  
            console.log(divarray[i]);                                                    
            if (dataAttribute !== null) {                                           
                dataAttribute = dataAttribute.replaceAll("props", this.propsname);
            }                                                              
            console.log(dataAttribute );
    }
}

這可以通過將 jsconfig.json 目標更改為 es2021 來解決,因為 String.replaceAll 是 ES2021 功能。

例子:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es2021",
        "jsx": "preserve",
        "strictFunctionTypes": true
    },
    "exclude": [
        "node_modules",
        "**/node_modules/*"
    ],
    "include": [
        "**/**/*"
    ]
}

老實說,您可以忽略這一點。 這只是一個 VS Code 的事情。 我假設它有效? 我自己制作了未給定的價值道具,效果很好。

如果你真的想解決這個問題,你必須將你的 jsconfig.json 目標更改為“es2021”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM