如何使用氚删除一段javascript文本



我有一段氚文本,用来删除一段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(),它仍然不起作用,谢谢。

嗨,请验证mixer stdlib是否存在于mixer.loc文件中,然后尝试使用以下替换:http://www.tritium.io/current#Text.replace(Regexp%20%25搜索,%20Text%20%25带)

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

这应该行得通。

Juan Camilo