【问题标题】:Not able to understand why computed doesn't work without watch无法理解为什么计算在没有手表的情况下无法工作
【发布时间】:2021-11-26 20:10:55
【问题描述】:

下面的惯性js和vue的代码只能这样工作

computed: {
        flash: function () {
            if (this.$page.props.flash.message) {
                this.$toast.open({
                    type: this.$page.props.flash.type,
                    message: this.$page.props.flash.message.message,
                })
            }
            return this.$page.props.flash.message
        }
    },
    watch: {
        flash: function (newVal, oldVal) {
        }
    },

但如果我移除手表部件,它就不起作用。另外,如果我把吐司部分放在手表里,它就不起作用。有人面临同样的问题吗?我正在 laravel 8 上使用惯性js。

【问题讨论】:

    标签: laravel vuejs2 toast inertiajs


    【解决方案1】:

    试试这个

    computed: {
        flash(){
            if (this.$page.props.flash.message) {
                this.$toast.open({
                    type: this.$page.props.flash.type,
                    message: this.$page.props.flash.message.message,
                })
            }
            return this.$page.props.flash.message
        }
    },
    

    【讨论】:

    • 谢谢。但不幸的是,对我来说,你的答案不起作用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多