<body> <div class="row"> <div class="col-md-4 col-md-offset-4"> <table class="table table-bordered"> <tr> <td> 商品分类 </td> <td> <select v-model="cid"> <template v-for="vo in goodscategory"> <option v-bind:value="vo.goodscategory_id">{{vo.goodscategory_name}}</option> </template> </select> {{cid}} </td> </tr> <tr> <td> 商品名称 </td> <td> <input type="text" v-model="goodsname" value=""/> <span>{{ goodsname }}</span> </td> </tr> <tr> <td> 排序 </td> <td> <input type="text" v-model="sort"/> {{sort}} </td> </tr> <tr> <td> 价格 </td> <td> <input type="text" v-model="price"/> {{price}} </td> </tr> <tr> <td> 商品描述 </td> <td> <textarea cols="30" rows="5" v-model="desc"></textarea> {{desc}} </td> </tr> <tr> <td colspan="2"> <button type="button" v-on:click="submit">提交</button> </td> </tr> </table> </div> </div> <script type="text/javascript"> var vm = new Vue({ el:"#content", data: { cid:0, goodsname:"", sort:0, price:0, desc:"", goodscategory:[] }, methods: { submit: function () { this.$http({ url: ‘‘, method: ‘POST‘, emulateJSON: true, data: { cid: this.cid, name: this.goodsname, sort: this.sort, price: this.price, desc: this.desc } }).then(function(response) { console.log(response.data); }, function(response) { }); } }, ready: function() { var self = this; this.$http({url: ‘‘, method: ‘POST‘}).then(function (response) { self.$set(‘goodscategory‘, response.data) }, function (response) { // error callback }); } }) </script>
,