Durundal Google Translate

后端 未结 2 614
遥遥无期
遥遥无期 2021-01-28 17:37

How can I bind Google translate in Durundal Shell.js , shell.html?

html

script<

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-28 18:23

    Durandal doesn't render script tags within views. To render them, you should use knockout custom bindings:

    ko.bindingHandlers.googleTranslate = {
      update: function( element, valueAccessor, allBindingsAccessor, viewModel, bindingContext){
        var googleElement = valueAccessor();
        $(element).html(' ');
      }
    };
    

    Use it in your shell.html:

提交回复
热议问题