@@ -11,7 +11,7 @@
<body>
<div id="myApp">
- <input type="button" @click="get()" value="点我异步获取数据(Get)">
+ <input type="button" @click="btnGet()" value="点我异步获取数据(Get)">
</div>
<script>
var vm = new Vue({
@@ -20,17 +20,21 @@
msg: 'Hello World!',
},
methods: {
- get: function() {
+ btnGet: function() {
//发送get请求
var data = {
a: 1,
b: 2
};
this.$http.get('ajax_info.txt', data).then(function(res) {
+ document.write("<h3>已经获取到数据:</h3>");
document.write(res.body);
}, function() {
console.log('请求失败处理');
});
+ },
+ btnPost:function(){
+ //post请求
}
@@ -1,24 +0,0 @@
-<!DOCTYPE html>
-<html lang="zh">
-
-<head>
- <title></title>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
- <link href="../css/style.css" rel="stylesheet"> </head>
-<body>
-<div id="myApp">
-</div>
-<script>
- var myApp = new Vue({
- el: '#myApp',
- data: {
- },
- });
-</script>
-</body>
-</html>