vue.js用select實現省,市,提交後,預設顯示省,市資訊

來源:互聯網
上載者:User

標籤:城市   錯誤   log   pre   mod   val   .ajax   ext   sel   

<select v-model="citys" name="cityVal" @change="schoolName(citys)">
        <option v-for="(item,index) in city" :value="item.val" v-text="item.name" ></option>
</select>

 

<select v-model="schools" name="schoolVal">
         <option v-for="(item,index) in school" :value="item.val" v-text="item.name" ></option>
 </select>

 

<script>    var vue = new Vue({        el: ‘#body‘,        data: function() {            return {                city: [{                    val: ‘0‘,                    name: ‘城市‘                }],                citys: 0,                school: [{                    val: ‘0‘,                    name: ‘高校‘                }],                schools: 0,                schoolAjax:‘‘            }        },        methods: {            cityName: function() {                var this_obj = this;                $.ajax({                    type: "post",                    url: $app+"/Clan/city",                    dataType: "json",                    success: function(res) {                        if(res.status) {                            $.each(res.info,function(k, v) {                                this_obj.city.push({                                    name:v.ar_name,                                    val:v.ar_id,                                })                            })                                                    } else {                                                    }                    },                    error: function() {                        $.alert({                            msg: ‘傳輸錯誤1‘                        })                    }                });            },            schoolName: function(citys) {                var this_obj = this;                    var data = { ar_id:citys};                                $.ajax({                    type: "post",                    data:data,                    url: $app+"/Clan/school",                    dataType: "json",                    success: function(res) {                        this_obj.school=[{ val: ‘0‘,name: ‘高校‘}]                        if(res.status) {                            $.each(res.info,function(k, v) {                                this_obj.school.push({                                    val:v.sc_id,                                    name:v.sc_name                                })                            });                                this_obj.schools=this_obj.schoolAjax;                        } else {                                                },                    error: function() {                        $.alert({                            msg: ‘傳輸錯誤7‘                        })                    }                });            },            defules:function(){                var this_obj = this;                $.ajax({                    type: "post",                    url: $app+"/Call/team_user",                    dataType: "json",                    success: function(res) {                        console.log(res.info);                        if(res.status) {                                                                this_obj.schoolName(res.info.us_arid);                                this_obj.schoolAjax=res.info.us_scid;                                                                        } else {                        }                    },                    error: function() {                        $.alert({                            msg: ‘傳輸錯誤5‘                        })                    }                });            }            }    })        vue.cityName();       vue.defules();

 

vue.js用select實現省,市,提交後,預設顯示省,市資訊

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.