我面临一个问题,我用cookies 解决它,但我想在没有cookies 的情况下解决这个问题.我有一个名为app header的组件,还有一个名为outmodal的组件.

var vue = new Vue({
    el : "html",
    data : {
        title       : "Site Title",
        description : "description of page",
        keywords    : "my keywords",
        view        : "home",
        login       : "login"
    },
    components:{
        "app-header" :require("../../components/header"),
        "app-footer" :require("../../components/footer"),
        "home"       :require("../../views/home")
    },
});

应用程序头的代码

var Vue     = require("vue");

Vue.partial("login",require("../../partials/login.html"));
Vue.partial("logged",require("../../partials/logged.html"));

module.exports = {
    template    : require("./template.html"),
    replace     : true,
    components  : {
        outmodal : require("../outmodal")
    },
    props : ['login']
}

输出模式代码

var Vue = require("vue");
Vue.partial("loginModal",require("../../partials/loginModal.html"));

module.exports = {
    template    : require("./template.html"),
    replace     : true,
    props       : ['name'],
    data        : function () {
            return  {
                userLogin : { mail  :   "", password    :   "", remember    :   ""}
            }

    },
    methods : {
        formSubmit : function(e){
                e.preventDefault();
                this.$http.post("http://example.com/auth/login",{ "email": this.userLogin.mail , "password": this.userLogin.password },function(data,status,request){
                    $.cookie("site_token",data.token,{expires : 1})
                }).error(function(data,status,request){

                });

        }
    }, ready  : function(){
        console.log("it works")
    }
}

在outmodal组件中,我连接API并判断登录,如果登录成功,我想更改Vue实例中登录变量的值.我使用WebPack来构建所有需要的功能.所以我不知道如何在这些文件之间绑定数据.

我该怎么解决呢?我

Vue.js相关问答推荐

无论条件解析为假,V-If元素都会显示

Vuetify 3 改变 Select 的 colored颜色

Vue 2 如何在全局函数中返回观察者

VSelect - Select 不适用于 Vuetify 3 中的自定义项目插槽

Webpack 编译错误:TypeError: __WEBPACK_IMPORTED_MODULE_1__ … is not a function

Webpack - MiniCssExtractPlugin 不提取文件

webpack vue-loader 配置

如何在 Nativescript 应用程序中调用 axios/api 调用

是否可以让 html-webpack-plugin 从 css 生成