Ibm mobilefirst 在ibm mobiefirst multiapp中加载页面时调用js函数

Ibm mobilefirst 在ibm mobiefirst multiapp中加载页面时调用js函数,ibm-mobilefirst,Ibm Mobilefirst,我正在尝试开发一个多页面应用程序,可以加载多个页面,但我的任务是在加载页面2时,我需要运行page2函数hello 当点击func“change”时,我可以加载第2页,但我需要运行函数“hello” main.js var pagesHistory = []; var currentPage = {}; var path = ""; var busyIndicator = null; function wlCommonInit(){ busyIndicator = new WL.Bu

我正在尝试开发一个多页面应用程序,可以加载多个页面,但我的任务是在加载页面2时,我需要运行page2函数hello

当点击func“change”时,我可以加载第2页,但我需要运行函数“hello”

main.js

var pagesHistory = [];
var currentPage = {};
var path = "";
var busyIndicator = null;


function wlCommonInit(){
    busyIndicator = new WL.BusyIndicator();

    // Special case for Windows Phone 8 only.
    if (WL.Client.getEnvironment() == WL.Environment.WINDOWS_PHONE_8) {
        path = "/www/default/";
    }

    $("#pageload").load(path + "pages/page1.html", function(){
        $.getScript(path + "js/page1.js", function() {
            if (currentPage.init) {
                currentPage.init();
            }
        });
    });
}
index.html

<!DOCTYPE HTML>
<html>
        <head>
            <meta charset="UTF-8">
            <title>demo</title>
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
            <!--
                <link rel="shortcut icon" href="images/favicon.png">
                <link rel="apple-touch-icon" href="images/apple-touch-icon.png"> 
            -->
            <link rel="stylesheet" href="css/main.css">
            <script>window.$ = window.jQuery = WLJQ;</script>
        </head>
        <body style="display: none;">
            <div id="pageload">
            </div>

            <script src="js/initOptions.js"></script>
            <script src="js/main.js"></script>
            <script src="jquery-2.1.4.min.js"></script> 
            <script src="jquery.touchSwipe.min.js"></script>
            <script src="js/messages.js"></script>
        </body>
</html>
页面1.html

<script>
    $.getScript(path + "js/page1.js");
</script>
<input type="button" value="click" onclick="funcchange();">
页面2.html

<script>
    $.getScript(path + "js/page2.js");
</script>

$.getScript(路径+“js/page2.js”);

您只需在main.js中创建一个函数:

function wlCommonInit() {
    ...
    ...
}

function test() {
    alert ("test");
}

然后在Page2.js中,只需调用
test()

这与示例应用程序有何不同?这就是它所做的吗?我的情况是,当加载第2页时,我需要加载运行2页js函数的2页js函数
<script>
    $.getScript(path + "js/page2.js");
</script>
function wlCommonInit() {
    ...
    ...
}

function test() {
    alert ("test");
}