源代码 :
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Vue 测试实例 - 开源教程(ossoft.cn)</title> <script src="https://unpkg.com/vue@next"></script> <script src="https://unpkg.com/axios/dist/axios.min.js"></script> </head> <body> <div id="app"> {{ info }} </div> <script> const app = { data() { return { info: null } }, mounted () { axios .post('/try/ajax/demo_axios_post.php') .then(response => (this.info = response)) .catch(function (error) { // 请求失败处理 console.log(error); }); } } Vue.createApp(app).mount('#app') </script> </body> </html>
运行结果