vue入门

103 阅读1分钟
 let app = new Vue({            el: '#app',            data() {                return {                    name: '',                    path: '',                    brands: []                }            },            methods: {                async save() {                    let res = await axios.post('http://simbajs.com:89/sys/savefl', {                        name: this.name,                        path: this.path                    })                    this.name = this.path = ''                    if (res.data.success)                        this.getList()                },                async del(id) {                    let res = await axios.post('http://simbajs.com:89/sys/removefl', {                        id                    })                    if (res.data.success)                        this.getList()                },                async getList() {                    let res = await axios.get('http://simbajs.com:89/sys/firendslink')                    this.brands = res.data                }            },            created() {                this.getList()            },        })

async  这里的async是异步执行 通过对getlist的封装 可以在代码中多次是使用 不用再次书写代码  只需调用即可  在 async save()   async del(id)  中调用  this.getList()  是因为当用户删除 或添加时能够及时获取和刷新页面数据实现动态获取