<!DOCTYPE html> |
<html> |
<head> |
<title></title> |
<script src= "https://cdn.jsdelivr.net/npm/vue@2.5.13/dist/vue.js" ></script> |
<script src= "https://cdn.jsdelivr.net/vue.resource/1.0.3/vue-resource.min.js" ></script> |
</head> |
<body> |
<!-- <div id= "example-5" > |
<select v-model= "selected" > |
<option disabled value= "" >请选择</option> |
<option>A</option> |
<option>B</option> |
<option>C</option> |
</select> |
<span>Selected: {{ selected }}</span> |
</div> |
<script type= "text/javascript" > |
new Vue({ |
el: '#example-5' , |
data:{ |
selected: '' |
} |
}) |
</script> --> |
<div id= "box" > |
<input type= "button" @click= "get()" value= "按钮" > |
</div> |
<script type= "text/javascript" > |
window.onload = function (){ |
var vm = new Vue({ |
el: '#box' , |
data:{ |
msg: 'Hello World!' , |
}, |
methods:{ |
get: function (){ |
//发送get请求 |
this .$http.get( 'a.txt' ).then( function (res){ |
alert(res.body); |
}, function (){ |
console.log( '请求失败处理' ); |
}); |
} |
} |
}); |
} |
</script> |
</body> |
</html> |