dimanche 25 septembre 2016

Laravel 5.2 Vue.js computed doesn't work

How can I show objects returned by vue? The provinces are Ok, But cities v-for doesn't work.

This is My Blade :

<select v-model="ProvinceModel" name="province" id="province" class="border-radius-0 form-control padding-y-0">
    <option v-for="province in provinces" value="@"> @ </option>
</select>

<select name="city" id="city" class="border-radius-0 form-control padding-y-0">
    <option v-for="city in cities" value="@"> @ </option>
</select>

This is my scripts

new Vue({
        el: '#vue',
        methods: {
            fetchProvinces: function () {
                this.$http.get('').then(function (provinces) {
                    this.$set('provinces', provinces.data)
                });
            }

        },
        computed: {
            cities() {
                this.$http.get("/" + this.ProvinceModel).then(function (cities) {
                    console.log(cities.data);
                    this.$set('cities', cities.data)
                });

            }
        },
        ready: function () {
            this.fetchProvinces()
        },
    });

And route

Route::get('cities/{provinces_id}', function ($id = 8) {
    return \App\province::find($id)->cities()->get();
})->where('id', '[0-9]+');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire