vue methods中的方法无法给data中的变量赋值

来源:4-5 单页面应用Demo2(2)

慕尼黑8203826

2019-10-05 11:59

data() {
    return {
        count: 0,
        isReg: false,
        name: '',
        password: '',
        repeat: ''
    }
},
methods: {
    login: function () {
        if (localStorage.getItem('name') == this.name && localStorage.getItem('password') == this.password) {
            this.$router.push('/home')
        } else {
            alert('用户名或者密码错误')
        }
    },
    reg: function () {
        this.isReg = true//赋值无效
        this.count++
    },
写回答 关注

1回答

  • Brian
    2019-10-08 10:11:00

    你确定你的reg方法执行了吗?

    有没有debug过?

    这里可以这么样赋值啊!

3小时速成 Vue2.x 核心技术

带你快速学习最流行的前端框架vue2.x的核心技术

82558 学习 · 487 问题

查看课程

相似问题