實(shí)際上我的問題標(biāo)題表述的是由問題的,但是又找不到好的切題的表述 … 希望大神能進(jìn)來吧<script language="JavaScript"> var app = { state: 0, page: {}, post: { getArticleList: function(){ console.log(app.page.pn); $.post('http://www.xxx.com.cn/api.php/Article/GetArtList',{ 'page': 1 },function(res){ console.log(app.page.pn); //console.log(app.page.$data.articleList); if(res.data.length > 0){ app.page.articleList = app.page.articleList.concat(res.data); app.page.pn = app.page.pn+1; } }); } } }; $(function(){ app.page = new Vue({ el: '#article-list', data: { pn: 3, articleList: [] }, methods: { doAjaxLoad: function(){ app.post.getArticleList(); } }, created: function(){ //console.log(this.pn); this.doAjaxLoad(); } }); //加載頁面 //app.post.getArticleList(); });</script>代碼如上,VUE生命周期 created 的時(shí)候,執(zhí)行自定義方法 doAjaxLoaddoAjaxLoad 這個(gè)方法調(diào)用全局對象 app 里的 post 對象里的 getArticleList 方法問題來了為什么我在getArticleList方法一開始輸出 vue 實(shí)例的 data 屬性 pn 的值的時(shí)候是 undefined在ajax callback里就能取值甚至我在 doAjaxLoad 方法里輸出 this.pn 也是有值的 ??!為什么 ?原理 …
vue實(shí)例對象data屬性訪問不到值的問題
12345678_0001
2019-03-12 17:19:23