简体   繁体   English

为什么我的javaScript函数不触发?

[英]Why aren't my javaScript functions firing?

I can't figure out what is keeping my functions from firing. 我不知道是什么阻止了我的功能。 I'm coding on the Appcelerator Studio and have four js files I am pulling from. 我正在Appcelerator Studio上编码,并且有四个要从中提取的js文件。 Here is the code for one of the functions that wont fire. 这是不会触发的功能之一的代码。

app.js file app.js文件

    var ui = require("win");

    var geo = require("geo");
    geo.getGeo;

geo.js file geo.js文件

    var getGeo =  function() {
        console.log("Geo Module");
        Ti.Geoloaction.purpose = "Your location is needed to get your weather forecast.";
        Ti.Geolocation.getCurrentPosition(function(a){
            console.log(a);
            console.log(JSON.stringify(a.source));
            var userLoc = {
                lat : a.cords.latitude,
                lng : a.cords.longitude
            };
        });
        //win.buildGeoUi;
        net.netFnc;
        console.log(userLoc.lat, userLoc.lng);
    };

    exports.getGeo = getGeo;

This is for a weather app for a school project. 这是用于学校项目的天气应用程序。 I am also trying to pull data from an api which is nested inside a function as well. 我也试图从嵌套在函数内的api中提取数据。

When I run my app the console.logs i have inside of my getGeo function are not running, this is how I know it is not firing the function. 当我运行我的应用程序时,我在getGeo函数内部的console.logs没有运行,这就是我知道它没有触发该函数的方式。

Your are doing geo.getGeo; 您正在做geo.getGeo; and you should do geo.getGeo(); 并且您应该执行geo.getGeo(); to execute the function. 执行功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM