zoukankan      html  css  js  c++  java
  • vue6 发请求

    <!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>
  • 相关阅读:
    剑指offer系列40:构建乘积数组
    自学网站
    存储分析--- 转载
    程序员面试宝典第四版
    资源查找
    诗句
    fifo manage
    charlse抓包
    python基础之-----列表list工厂的仓库
    python内置函数积累
  • 原文地址:https://www.cnblogs.com/yaowen/p/6974360.html
Copyright © 2011-2022 走看看