zoukankan      html  css  js  c++  java
  • axios 和 element的使用

    https://www.cnblogs.com/jflalove/p/11944483.html

    https://blog.csdn.net/qq_40236722/article/details/88175015

    axios的使用:

              

    /**
     * 
     *    使用axios的步骤;
     *    第一步安装 npm install --save axios vue-axios
          第二步,在mian.js中导入和配置,  (这是全局的axios)
        引入:
                         import axios from 'axios'

                         Vue.use(axios)
        配置 :
                         axios.defaults.baseURL="https://wd4363557576ckikwp.wilddogio.com/"
          第三步在你要使用的文件下引用axios
     
     
     */
        第二种配置
            import axios from 'axios'配置axios

       与很多第三方模块不同的是,axios不能使用use方法,转而应该进行如下操作

    引用axios

        axios 发送数据:

                

    复制代码
        const fromData={
                 age:this.ruleForm.age,
                 pass:this.ruleForm.pass
               }
               //发送数据
               axios.post('./axiosT.json',fromData)
               .then(res=>{//当数据发送成功时回调
               console.log("数据发送成功")
               console.log(res.data)
               
               })
               .catch((error)=>{
                 console.log(error)
               })
    复制代码

         接受数据:

              

    复制代码
          mounted () {
                var that = this
                axios.get('/Produce.json')
                .then(function(response){
                    console.log(response.data)
                    that.produce=response.data
                })
           .catch(error => console.log(error))//检查问题 :例如
    •                                                                API 不工作了;
    •                                                                请求发错了;
    •                                                                API 没有按我们预期的格式返回信息。
          }
    复制代码

             elementUi的使用:

            

    复制代码
    vue.esm.js?efeb:628 [Vue warn]: Unknown custom element: <el-carousel> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
    
    found in
    
    ---> <ElementUi> at src/components/elementUi.vue
           <App> at src/App.vue
             <Root>
    复制代码

          这个错误是因为没有注册组件在main.js里面

            

    import ElementUI from 'element-ui';
    import 'element-ui/lib/theme-chalk/index.css';        //注册组件
    Vue.use(ElementUI);
  • 相关阅读:
    Jquery Validate验证是否为图片格式
    cosbench read异常解决办法。 Unable to verify integrity of data download. Client calculated content hash didn't match hash calculated by Amazon S3. The data may be corrupt.
    Ceph RGW 和 niginx 配置要点
    RGW/SWIFT对象存储性能测试工具--COSBench安装
    CEPH DAYS 2016 APAC ROADSHOW Ceph社区分享资料
    使用s3cmd操作ceph rgw
    gdb调试常用实用命令和core dump文件的生成
    What is GSLB
    转 ext文件系统及块组
    转 浅谈算法和数据结构: 十 平衡查找树之B树
  • 原文地址:https://www.cnblogs.com/rxbook/p/12682144.html
Copyright © 2011-2022 走看看