账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    axios,post请求问题
    36
    0

    我有一个组件,组件里面写的是axios

    import axios from 'axios'
    
    export function POST(URL, params) {
      return new Promise((resolve, reject) => {
        var link = process.env.HOST + URL
        axios({
          method: "POST",
          url: link,
          data: params
        }).then(resolve, reject)
      })
    }
    

    现在想在另一个页面里上传文件,post请求,现在讲这个axios组件引入进来,不会使用,请问如何设置为好?

     <form action="" method="post" enctype="multipart/form-data" id="upload">
            <label>Select file:</label>&nbsp;&nbsp;&nbsp;&nbsp;
            <p class="wrap">
              <input type="file" ref="reffile" name="file" @change="changeselect">
            </p>
            <input class="submit" type="submit" value="Select file" onclick="submitForm($event)"/>
          </form>
            import Axios from '../request/index'
            Vue.prototype.$axios = Axios;
    
       created(){
            this.$axios.post('url').then(res=>{
              this.data =res.data.message;
              console.log(res)
    
            })
              .catch(err=>{
                console.log(err)
              })
          }
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部