引入的js:
<script src="js/vue.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/vue-resource.min.js" type="text/javascript" charset="utf-8" defer="defer"></script>
代码:
var vm = new Vue({
el: "#app",
ready: function(){
this.$http.get('data/list.txt', function(data) {
console.log(data);
}).error(function(data, status, request) {
console.log('fail' + status + "," + request);
})
},
data:{}
});
报错:index.html:24 Uncaught TypeError: Cannot read property 'get' of undefined
代码没看出来什么明显的错误,唯独
<script src="js/vue-resource.min.js" type="text/javascript" charset="utf-8" defer="defer"></script>
里面的defer="defer"
不明就里,去掉再试试。Vue.use(VueResource)
加了没有
附我的 源码实例一枚 https://github.com/papersnake/newdenfaces-vue/blob/master/src/main.js