<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Vue 测试实例 - 菜鸟教程(runoob.com)</title> <script src="https://cdn.bootcss.com/vue/2.2.2/vue.min.js"></script> <script src="https://cdn.bootcss.com/vue-resource/1.5.1/vue-resource.min.js"></script> </head> <body> <div id="app"> <ol> <li v-for="site in sites"> [[ site.username ]] </li> </ol> </div> <script> var demo = new Vue({ el: '#app', data: { sites: [], apiUrl: '/api/app/user/?format=json' }, mounted: function() { this.getCustomers() }, methods: { getCustomers: function() { var _this = this; this.$http.get(this.apiUrl) .then((response) => { _this.sites =response.data; console.log(_this.sites) }) } }, delimiters : ['[[', ']]'], }) </script> </body> </html>
django中,用vue.js获取后端json数据并加载
最新推荐文章于 2024-04-16 20:11:09 发布