未命名 发表于 2022-1-9 16:03:41

axios 请求发起和数据渲染VUE

axios 请求发起和数据渲染VUE
<script>
//引入
import axios from "axios";
export default {
// name: 'cs',
data () {
   return {
      msg1: []
      }
},
methods:{
       getData(){
               
               axios.post('http://127.0.0.7/chanpin.php', {
                         sex: '1',
                         age: '2'
                   })
                         .then(res=>{
                            
                                              this.msg1=res.data.rows
                                                  console.log(res.data.rows);
                         })
                         .catch(function (err) {
                             console.log(err);
                         });
                                       
          }
        },
        mounted(){
          this.getData()
        },
}
</script>

前端代码为:
</div>
                              <div id="cs" class="overview-box-count">{{msg1}}</div>
                              <div class="overview-box-stats">相比昨天减少12</div>
                        </div>

页: [1]
查看完整版本: axios 请求发起和数据渲染VUE