菜单切换
FACESOHO知行者
心灵
记录
远方
赞赏工具
源代码:
点击运行
保存
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Vue 测试实例 - 小鸟启蒙(facesoho.com)</title> <script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script> <script src="https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js"></script> </head> <body> <div id="box">{{msg}}<hr> <input type="button" @click="get()" value="点我异步获取数据(Get)"> </div> <script type = "text/javascript"> window.onload = function(){ var vm = new Vue({ el:'#box', data:{ msg:'劝君更尽一杯酒,西出阳关无故人。',}, methods:{ get:function(){//发送get请求 this.$http.get('/demos/wish-time-not-old.html').then(function(res){ this.msg=res.body; },function(){ this.msg='请求失败处理'; }); } } }); } </script> </body> </html>
运行结果