Uncaught ReferenceError: wlInitOptions is not defi

2019-01-20 20:31发布

问题:

I'm getting this error since i upgraded my worklight developer edition to v5.0.6:

wlclient init started worklight.js:1118
Uncaught ReferenceError: wlInitOptions is not defined

回答1:

Look inside your application's js folder (yourProject\apps\yourApp\common\js). Make sure it contains an initOptions.js file and that its content is as follows (you can also create a new application and copy the file from there):

var wlInitOptions = {

    // # Should application automatically attempt to connect to Worklight Server on application start up
    // # The default value is true, we are overriding it to false here.
    connectOnStartup : false
};

if (window.addEventListener) {
    window.addEventListener('load', function() { WL.Client.init(wlInitOptions); }, false);
} else if (window.attachEvent) {
    window.attachEvent('onload',  function() { WL.Client.init(wlInitOptions); });

In addition, the HTML file must not contain a call to WL.Client.init in the <body> tag. It should look like this:

<body id="content" style="display: none;">