【问题标题】:How can I remove a piece of javascript text with tritium?如何使用氚删除一段 javascript 文本?
【发布时间】:2015-02-20 16:42:43
【问题描述】:

我有这段氚文本,我将使用它来删除一段 javascript 代码。

  # to remove an inline js code based on text search
      $("//script[contains(text(),'textiwanttoremove')]") {
          text(){
              replace('thetextiwanttoremove','')
          }
      }

但是,此代码不起作用。我收到一个错误,

Failed to create body.ts transformer: 
scripts/main.ts:13: function Text.$(Text) does not exist in namespace tritium; (called from Text.with(Regexp)).

另外,如果我用inner()替换text(),还是不行,谢谢。

【问题讨论】:

    标签: xml xpath find tritium


    【解决方案1】:

    您好,请确认您的 Mixer.loc 文件中存在混音器标准库,然后尝试使用以下替换: http://www.tritium.io/current#Text.replace(Regexp%20%25search,%20Text%20%25with)

     $(".//script[contains(text(), 'txt2remove')]") {
        text() {
          replace(/txt2remove/, '') 
        }
     }
    

    应该可以的。

    胡安·卡米洛

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多