Javascript 特定的vue mixin函数不';我不会被处决

Javascript 特定的vue mixin函数不';我不会被处决,javascript,vue.js,mixins,Javascript,Vue.js,Mixins,我将Vue.js与全局函数一起使用,这些函数是我在Vuemixin下定义的。在我的组件中,我从这个Vue调用不同的函数mixin。但是,每当我尝试调用只包含console.log(…)行的checkUser时,什么都不会发生。甚至在控制台中也不会打印该行 但是我想知道,为什么这个mixin的其他函数,例如handleSubmit从同一个组件调用和执行时没有任何问题。即使在相同的功能中。。。。我甚至尝试重命名该函数,但都不起作用。。这也不是缓存问题,因为mixin上的其他更改可以工作,我在浏览器中

我将Vue.js与全局函数一起使用,这些函数是我在Vue
mixin
下定义的。在我的组件中,我从这个Vue调用不同的函数
mixin
。但是,每当我尝试调用只包含
console.log(…)
行的
checkUser
时,什么都不会发生。甚至在控制台中也不会打印该行

但是我想知道,为什么这个
mixin
的其他函数,例如
handleSubmit
从同一个组件调用和执行时没有任何问题。即使在相同的功能中。。。。我甚至尝试重命名该函数,但都不起作用。。这也不是缓存问题,因为
mixin
上的其他更改可以工作,我在浏览器中刷新
app.js
文件,并可以看到更改

我的目标是检查用户是否登录,以及是否显示错误消息。因此,在发出
axios
请求之前需要调用
checkUser
函数,
axios
请求需要等待
checkUser
函数返回
true
false
。我知道我需要一个
if语句
,但是,首先我想弄清楚为什么我的函数现在被调用了

这是我的源代码。如果你需要更多,让我知道。。。 app.js

组成部分

<template>
    <div @click="toogleProductMark">
        <p>Toogle Product Mark</p>
    </div>
</template>

<script>
    export default {
        name: "ProductListView",
        methods: {
            toogleProductMark(){
                this.checkUser(true); // <-- WHY is this line not getting executed?

                if(this.product.isMarkedAuthUser){
                    axios.post(this.product.actions.unmark.route, {value: 1})
                        .then((r) => {
                            this.product.isMarkedAuthUser = false;
                        }).catch((e) => {
                        this.handleSubmitError(e); // <-- BUT this does?
                    });
                }else if(!this.product.isMarkedAuthUser){
                    axios.post(this.product.actions.mark.route, {value: 1})
                        .then((r) => {
                            this.product.isMarkedAuthUser = true;
                        }).catch((e) => {
                        this.handleSubmitError(e); // <-- AND this as well?
                    });
                }
            }
        }
    }
</script>

图格尔产品标志

导出默认值{ 名称:“ProductListView”, 方法:{ toogleProductMark(){ this.checkUser(true);//{ this.product.isMarkedAuthUser=false; }).catch((e)=>{ 此.可操作SubmitError(e);//{ this.product.isMarkedAuthUser=true; }).catch((e)=>{
this.handleSubmitError(e);//我该如何做,为什么
handleSubmitError
可以工作?这里它的工作方式与我实现的一样:在这里,您还可以看到它可以全局工作,而不必为每个组件定义它:
<template>
    <div @click="toogleProductMark">
        <p>Toogle Product Mark</p>
    </div>
</template>

<script>
    export default {
        name: "ProductListView",
        methods: {
            toogleProductMark(){
                this.checkUser(true); // <-- WHY is this line not getting executed?

                if(this.product.isMarkedAuthUser){
                    axios.post(this.product.actions.unmark.route, {value: 1})
                        .then((r) => {
                            this.product.isMarkedAuthUser = false;
                        }).catch((e) => {
                        this.handleSubmitError(e); // <-- BUT this does?
                    });
                }else if(!this.product.isMarkedAuthUser){
                    axios.post(this.product.actions.mark.route, {value: 1})
                        .then((r) => {
                            this.product.isMarkedAuthUser = true;
                        }).catch((e) => {
                        this.handleSubmitError(e); // <-- AND this as well?
                    });
                }
            }
        }
    }
</script>