Laravel Vue JS按钮在重定向时不会保持禁用状态

时间:2017-10-07 16:37:08

标签: javascript php laravel vue.js vuejs2

我的页面上有一个按钮,单击时会获取已禁用的属性,并且单击时会添加aria-disabled =“true”。但是,当页面重新加载按钮时,即使我将布尔值true传递给is,也不会保持禁用状态。我添加了一个警告,由于某种原因,即使buttonStat为true,我也会得到一个假值。

控制器

public function syncOrders() {
     return redirect('/orders')->with(compact('orders'))->with('buttonState', true);
}

查看

<sync-button v-cloak :active="{{ json_encode($buttonState) }}"></sync-button>

JS

<template>
    <button class="btn btn-primary" style="margin:5px;" 
     :disabled="isDisabled" :aria-disabled="isDisabled"
     @click="sync">Sync Orders</button></template>

<script>
    export default {
        props: ['active', 'old'],
        computed: {
            isDisabled() {
                return this.active;
            }
        },
        methods: {
            sync() {
                this.active = ! this.active;

            }
        }
    }
</script>

1 个答案:

答案 0 :(得分:0)

试试这个:

<sync-button v-cloak :active="{{ json_encode(session('buttonState')) }}"></sync-button>
相关问题