html与vue合并使用,axios和vue的使用.html

Document

vue 和 axios 配合使用

{{ item.title }}

const app = new Vue({

el: '#app',

data: {

todos:[]

},

methods: {

},

created () { // 当 Vue 渲染完成之后,会自动调用 created 函数

axios.get('http://localhost:3000/todos').then(res => {

// console.log(res.data)

this.todos = res.data

})

}

})

// axios.get('http://localhost:3000/todos').then(res => {

// app.todos = res.data

// })

// setTimeout(function () {

// axios({

// method: 'GET', // 不写请求默认是 get 请求

// url: 'http://localhost:3000/todos'

// }).then(res => {

// app.todos = res.data

// })

// }, 3000)

一键复制

编辑

Web IDE

原始数据

按行查看

历史