vue6 发请求
2024-08-30 23:52:15
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>智能社——http://www.zhinengshe.com</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<style> </style>
<script src="vue.js"></script>
<script src="vue-resource.js"></script>
<script>
window.onload=function(){
new Vue({
el:'body',
data:{ },
methods:{
get:function(){
this.$http.get('a.txt',{
a:1,
b:2
},{
emulateJSON:true//加这个参数才能post发送数据
}).then(function(res){
alert('成功了');
alert(res.data);
},function(res){
alert('失败了');
alert(res.data);
alert(res.status);
});
}
}
});
};
</script>
</head>
<body>
<input type="button" value="按钮" @click="get()">
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>智能社——http://www.zhinengshe.com</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<style> </style>
<script src="vue.js"></script>
<script src="vue-resource.js"></script>
<script>
window.onload=function(){
new Vue({
el:'body',
data:{ },
methods:{
get:function(){//jsonp跨域访问
this.$http.jsonp('https://sug.so.360.cn/suggest',{
word:'a'
}).then(function(res){
alert(res.data.s);
},function(res){
alert(res.status);
});
}
}
});
};
</script>
</head>
<body>
<input type="button" value="按钮" @click="get()">
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>智能社——http://www.zhinengshe.com</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<style> </style>
<script src="vue.js"></script>
<script src="vue-resource.js"></script>
<script>
window.onload=function(){
new Vue({
el:'body',
data:{ },
methods:{
get:function(){
this.$http.jsonp('https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su',{
wd:'a'
},{
jsonp:'cb' //callback名字
}).then(function(res){
alert(res.data.s);
},function(res){
alert(res.status);
});
}
}
});
};
</script>
</head>
<body>
<input type="button" value="按钮" @click="get()">
</body>
</html>
最新文章
- 解决mysql插入数据时出现Incorrect string value: &#39;\xF0\x9F...&#39; for column &#39;name&#39; at row 1的异常
- Spring中常用类型的bean配置(Map,List,Set,基本类型)
- Webdriver配合Tesseract-OCR 自动识别简单的验证码
- cocostudio 骨骼动画 setContentScaleFactor
- EmguCV 如何从数组中创建出IntPtr
- C#使用ICSharpCode.SharpZipLib.dll压缩文件夹和文件
- 在WPF控件上添加Windows窗口式调整大小行为
- 用正则表达式在注册页面(js/aspx.cs)的验证
- [翻译][MVC 5 + EF 6] 4:弹性连接和命令拦截
- hibernate官方新手教程 (转载)
- New Year Permutation(Floyd+并查集)
- js对象字面量
- 图解vue生命周期
- tomcat自动运行磁盘任意位置上的项目、使用Maven对tomcat进行自动部署
- node命令行工具—cf-cli
- 剑指Offer 17. 树的子结构 (二叉树)
- Redis基础认识及常用命令使用(一)--转载
- c# 泛型的应用
- 如何使用seajs+jQuery构建中型项目
- Eclipse中创建java类的时候自动设置作者信息和创建时间
热门文章
- 华为P30系列新增“无线投屏”功能
- python 正则表达式与re模块
- 中国象棋程序的设计与实现(六)--N皇后问题的算法设计与实现(源码+注释+截图)
- 解决jquery动态增加元素后children值没有变的问题
- 面向对象设计(OOD)七大原则
- CodeForces 550B Preparing Olympiad(DFS回溯+暴力枚举)
- 由老同事学习SAP所想到的
- SPOJ1812: LCS2 - Longest Common Substring II &; BZOJ2946: [Poi2000]公共串
- springboot actuator shutdown正确的关闭操作
- Java Web应用定制404错误页面