Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
842 views
in Technique[技术] by (71.8m points)

请教vue绑定问题

<div class="menu-right padding-all j-content" id="main">
      <div v-for="item in data">
        <p>姓名:{{item.Info}}</p>
      </div>
    </div>
  </div>
  <script src="/weui/lib/jquery-2.1.4.js"></script>
  <script src="/weui/lib/fastclick.js"></script>
  <script>
  $(function() {
    FastClick.attach(document.body);
  });
  </script>
  <script src="/weui/js/jquery-weui.js"></script>
  <script type="text/javascript">
      var data_result = {};
      var v = new Vue({
          el: '#main',
          data: {
              data: data_result
          }
      })
      
      $(function($) {
          $('#sidebar ul li').click(function() {
              var cid = $(this).data('class');
              console.log(cid);
              $(this).addClass('active').siblings('li').removeClass('active');
              var index = $(this).index();
              $('.j-content').eq(index).show().siblings('.j-content').hide();
              //接口Url
              var apiUrl = "http://m.xx.cn/index.php/Api/GetInfo";
              //请求参数
              var data = {
                  Field: 'InfoID,InfoTitle',
                  ChannelID: cid,
                  Top: 10
              };
              //使用Jquery库发送http请求

              $.get(apiUrl, data, function(data) {
                  if (data.Status == 1) {
                      //接口调用成功
                      data_result = data.Data;
                      console.log(data_result);
                      console.log(typeof(data.Data));

                  } else {
                      console.log(data);
                      //接口调用失败
                  }
              }, "json");
          })
      })
  </script>

点击一个链接,通过cid获取到数据
然后想通过vue显示在页面上,但是没有效果

image


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

请求成功后:

v.data = data.Data;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...