在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ vue ajax 不能綁定到 module

vue ajax 不能綁定到 module

    <script src="https://cdn.jsdelivr.net/npm/vue@2.5.13/dist/vue.js"></script>
    <script src="~/lib/jquery/dist/jquery.min.js"></script>

    <nav class="navbar navbar-fixed-top" id="sidebar-wrapper" role="navigation">
      <ul class="nav sidebar-nav" v-for="msg in messages">
        <li>
          <i class="fa fa-fw fa-cog"></i>
          {{ msg.impdepname }}
        </li>
      </ul>
    </nav>
    
<script>
     var vm = new Vue({
        el: '#sidebar-wrapper',
        data: {
          messages: []
        },
        mounted: function () {
          $.ajax({
            url: 'http://localhost:61754/api/services/emisapp/b_emis_confsumimp/getlistsquery',
            data: { "depid": "99007" },
            type: 'POST',
            dataType: 'json',
            success: function (data) {
              console.log(data);
              this.messages = data.result;
              console.log(this.messages);
            },
            error: function (error) {
              console.log(error);
            }
          });
        }
      });
</script>


能在命令行輸出數(shù)據(jù),但是 v-for 綁定的時候報錯

Uncaught ReferenceError: module is not defined    
moment-with-locales.min.js:1 

不知道是哪里出了問題。

回答
編輯回答
殘淚

this

    mounted: function () {
          var _this= this;
          $.ajax({
            url: 'http://localhost:61754/api/services/emisapp/b_emis_confsumimp/getlistsquery',
            data: { "depid": "99007" },
            type: 'POST',
            dataType: 'json',
            success: function (data) {
              console.log(data);
              _this.messages = data.result;
              console.log(_this.messages);
            },
            error: function (error) {
              console.log(error);
            }
          });
        }
2017年10月7日 10:57
編輯回答
玩控

看起來像是 moment 依賴報錯了,可以注釋掉引用 moment 的地方確認(rèn)下

2018年3月19日 20:48
編輯回答
萌二代
v-for="(msg,index) in messages" :key='index'

v-for這么寫,同時要保證messages是個數(shù)組

2018年3月30日 09:31