undefinedfix
Sign in

What's wrong with this way of writing?

Ori edited in Sat, 24 Sep 2022

What's wrong with this way of writing? Why is it different from writing then (function (RS) {} when RS cannot be found??

let vm = new Vue({
            el: '#wrap',
            data: {
                rs: ''
            },
            methods: {
                getData(type, url, dataObject, okcallback, ercallback) {
                    if (String(type).toLowerCase() == 'get' && dataObject) {
                        axios.get(url, {
                            params: dataObject
                        }).then(okcallback)
                            .catch(ercallback)
                    } else if (!dataObject) {
                        axios.get(url).then(okcallback)
                            .catch(ercallback)
                    } else {
                        axios.post(url, qs.stringfy(dataObject)).then(okcallback).catch(ercallback)
                    }
                },
                resultSuccess(rs) {
                    console.log('aaa');
                    // vm.rs = rs;
                    // console.log(vm.rs, rs);
                },
                resultError(err) {

                }
            },
            mounted() {
                console.log('mounted over');
                this.getData('GET', url,'', this.resultSuccess, this.resultError);
            },
        })
1 Replies
zcnfk
commented on Sat, 24 Sep 2022
getData(type, url, dataObject, okcallback, ercallback)
this.getData('GET', url, this.resultSuccess, this.resultError);

DataObject? Is the parameter in the wrong position

lock This question has been locked and the reply function has been disabled.