Javascript无法读取未定义的属性

时间:2019-04-14 00:50:00

标签: javascript vue.js

您好,我使用nativescript和vue.js(但在这种情况下可能没有任何意义)。

我像下面的代码一样导出类Update。在这一节课中,我得到了一些方法。我想从其他方法运行方法,但我无法从标题中接收错误。

[TypeError: Cannot read property 'someshit' of undefined]


import store from '../store';
import axios from 'axios';

export default class Update {

getMsgDB(){ // read msg if there are messages then perform alert
    axios.get(store.getters.jsonUsers + store.getters.ID + "/msg")
    .then(function (response) {
        console.log('getMsgDB fired updated');

        const msgCount = response.data.length;
        if ( msgCount > 0 ) {

            let i;
            var msg_arr = [];

            for (i = 0; i < msgCount; i++){
                msg_arr.push([
                    response.data[i].msgName,response.data[i].msg,response.data[i].id // additionally take id to make delete after read
                ])
            }


            msg_arr.forEach(function(value, i){

                dialogs.alert({
                    title: value[0],
                    message: value[1],
                    okButtonText: "OK"
                });     
            });

            // after display delete read msgs
            //this.deleteReadMsgs(msg_arr);
            this.someshit();

        }
    })
    .catch(function (error) {
        console.log(error);

    });


}

someshit(){
    console.log("someshit");
}

}

0 个答案:

没有答案