完全限定的javascript方法调用

完全限定的javascript方法调用,javascript,wpf,Javascript,Wpf,我正在尝试从客户端应用程序调用一些javascript。我的javascript从ES6传输到ES5 下面是它传输时的样子: System.register([], function (_export) { var _prototypeProperties, _classCallCheck, Welcome, UpperValueConverter; return { setters: [], execute: function () {

我正在尝试从客户端应用程序调用一些javascript。我的javascript从ES6传输到ES5

下面是它传输时的样子:

System.register([], function (_export) {
    var _prototypeProperties, _classCallCheck, Welcome, UpperValueConverter;

    return {
        setters: [],
        execute: function () {
            "use strict";

            _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };

            _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };

            Welcome = _export("Welcome", (function () {
                function Welcome() {
                    _classCallCheck(this, Welcome);

                    this.heading = "Welcome to the Aurelia Navigation App!";
                    this.firstName = "John";
                    this.lastName = "Doe";
                }

                _prototypeProperties(Welcome, null, {
                    fullName: {
                        get: function () {
                            return "" + this.firstName + " " + this.lastName;
                        },
                        configurable: true
                    },
                    welcome: {
                        value: function welcome() {
                            alert("Welcome, " + this.fullName + "!");
                        },
                        writable: true,
                        configurable: true
                    }
                });

                return Welcome;
            })());
        }
    };
});
export class Welcome{
  constructor(){
    this.heading = 'Welcome to the Aurelia Navigation App!';
    this.firstName = 'John';
    this.lastName = 'Doe';
  }

  get fullName(){
    return `${this.firstName} ${this.lastName}`;
  }

  welcome(){
    alert(`Welcome, ${this.fullName}!`);
  }
}

export class UpperValueConverter {
  toView(value){
    return value && value.toUpperCase();
  }
}
我尝试调用的方法是welcome()。在传输之前,它看起来是这样的:

System.register([], function (_export) {
    var _prototypeProperties, _classCallCheck, Welcome, UpperValueConverter;

    return {
        setters: [],
        execute: function () {
            "use strict";

            _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };

            _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };

            Welcome = _export("Welcome", (function () {
                function Welcome() {
                    _classCallCheck(this, Welcome);

                    this.heading = "Welcome to the Aurelia Navigation App!";
                    this.firstName = "John";
                    this.lastName = "Doe";
                }

                _prototypeProperties(Welcome, null, {
                    fullName: {
                        get: function () {
                            return "" + this.firstName + " " + this.lastName;
                        },
                        configurable: true
                    },
                    welcome: {
                        value: function welcome() {
                            alert("Welcome, " + this.fullName + "!");
                        },
                        writable: true,
                        configurable: true
                    }
                });

                return Welcome;
            })());
        }
    };
});
export class Welcome{
  constructor(){
    this.heading = 'Welcome to the Aurelia Navigation App!';
    this.firstName = 'John';
    this.lastName = 'Doe';
  }

  get fullName(){
    return `${this.firstName} ${this.lastName}`;
  }

  welcome(){
    alert(`Welcome, ${this.fullName}!`);
  }
}

export class UpperValueConverter {
  toView(value){
    return value && value.toUpperCase();
  }
}
我用WPF网络浏览器(C#)这样称呼它:

webBrowser.InvokeScript("Welcome.welcome");
我也尝试过只欢迎,但也不起作用

我在想,要调用它,我需要一些其他东西,但我对JavaScript太陌生,无法让它工作


如何从这个javascript“类”之外调用
welcome
函数?
welcome
在ES6代码中声明为实例方法。在调用该方法之前,您需要创建
Welcome
类的实例:

var welcome = new Welcome(); 
welcome.welcome();
不幸的是,对于
WebBrowser
控件,您首先需要将命名方法注入全局范围以处理该位代码:

var scriptEl = webBrowser.Document.CreateElement("script");
var scriptDomElement = (IHTMLScriptElement)scriptEl.DomElement;
scriptDomElement.text = "function welcome() { var w = new Welcome(); w.welcome(); }";

var head = webBrowser.Document.GetElementsByTagName("head")[0];
head.AppendChild(scriptEl);
webBrowser.Document.InvokeScript("welcome");

welcome
在ES6代码中声明为实例方法。在调用该方法之前,您需要创建
Welcome
类的实例:

var welcome = new Welcome(); 
welcome.welcome();
不幸的是,对于
WebBrowser
控件,您首先需要将命名方法注入全局范围以处理该位代码:

var scriptEl = webBrowser.Document.CreateElement("script");
var scriptDomElement = (IHTMLScriptElement)scriptEl.DomElement;
scriptDomElement.text = "function welcome() { var w = new Welcome(); w.welcome(); }";

var head = webBrowser.Document.GetElementsByTagName("head")[0];
head.AppendChild(scriptEl);
webBrowser.Document.InvokeScript("welcome");

welcome
在ES6代码中声明为实例方法。在调用该方法之前,您需要创建
Welcome
类的实例:

var welcome = new Welcome(); 
welcome.welcome();
不幸的是,对于
WebBrowser
控件,您首先需要将命名方法注入全局范围以处理该位代码:

var scriptEl = webBrowser.Document.CreateElement("script");
var scriptDomElement = (IHTMLScriptElement)scriptEl.DomElement;
scriptDomElement.text = "function welcome() { var w = new Welcome(); w.welcome(); }";

var head = webBrowser.Document.GetElementsByTagName("head")[0];
head.AppendChild(scriptEl);
webBrowser.Document.InvokeScript("welcome");

welcome
在ES6代码中声明为实例方法。在调用该方法之前,您需要创建
Welcome
类的实例:

var welcome = new Welcome(); 
welcome.welcome();
不幸的是,对于
WebBrowser
控件,您首先需要将命名方法注入全局范围以处理该位代码:

var scriptEl = webBrowser.Document.CreateElement("script");
var scriptDomElement = (IHTMLScriptElement)scriptEl.DomElement;
scriptDomElement.text = "function welcome() { var w = new Welcome(); w.welcome(); }";

var head = webBrowser.Document.GetElementsByTagName("head")[0];
head.AppendChild(scriptEl);
webBrowser.Document.InvokeScript("welcome");

您可能正在查找以下内容:

var instance = new Welcome();
instance.welcome(); // performs your alert.

您可能正在查找以下内容:

var instance = new Welcome();
instance.welcome(); // performs your alert.

您可能正在查找以下内容:

var instance = new Welcome();
instance.welcome(); // performs your alert.

您可能正在查找以下内容:

var instance = new Welcome();
instance.welcome(); // performs your alert.