当前位置:首页 > 操作系统 > Ios

vue.js+axios请求的简单请求示例

            <!
            DOCTYPE html
            >
            <
            html 
            lang
            ="en"
            >
            <
            head
            >
            <
            meta 
            charset
            ="UTF-8"
            >
            <
            title
            >Title</title><script src="./vue.min.js"></script><script src="./axios.min.js"></script></head><body><div id="app"><input type="button" value="获取笑话" @click="getJoke"><p>
        {{msg}}
    </p></div><script>var vm =new Vue({
        el:"#app",
        data:{
            msg:"hello world",
        },
        methods:{
            getJoke(){
          //axios.post(‘https://xxxxxx‘,{"usename":"小明"}) axios.get(
"https://autumnfish.cn/api/joke") .then((response)=>{ this.msg=response.data; },(err)=>{ this.msg=err.message; }) }, } }) </script></body></html>

 

原文:https://www.cnblogs.com/qxh-beijing2016/p/12654914.html


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!