为了账号安全,请及时绑定邮箱和手机立即绑定

没接触过mvvm,求问用vue怎么实现的?

没接触过mvvm,求问用vue怎么实现的?

啊啊啊啊123 2017-09-25 20:36:19
<div id="app">     <input type="text" id="a">     <input type="text" id="b">     <div id="c" class="active"></div>     <div id="d"></div></div><script>     $.ajax().done(function (data) {                 if (data.id ==1) {             $("#a").val(data.a);             $("#b").val(data.b);             $("#c").removeClass('active');             $("#d").addClass('active');         }     })</script>jq 对ajax的数据处理,怎么用vue实现上面的对数据的处理<div id="app">     <input type="text" id="a" v-model="msg.a">     <input type="text" id="b" v-model="msg.b">     <div id="c" :class="[c?'':cls]"></div>     <div id="d" :class="[d?'':cls]"></div></div><script>     $.ajax().done(function (data) {         vm = new Vue({                          el: '#app',                          data: {                              mydata: data,                              c: false,                              d: true,                              cls: 'active'             },                         computed: {                               msg: function () {                                       if (data.id == 1) {                                              this.c = true;                                              this.d = false;                                              return {                                                      a: this.mydata.a,                                                      b: this.mydata.b                         }                     }else {                                                  return {                                                         a: '',                                                         b: ''                         }                     }                 }             }         })     })</script>上面是我写的,总觉得不对,求问该怎么写
查看完整描述

1 回答

?
HalfAnHour

TA贡献52条经验 获得超73个赞

vue axios

查看完整回答
反对 回复 2017-09-26
  • 1 回答
  • 0 关注
  • 1595 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信