zoukankan      html  css  js  c++  java
  • vue+php接口

    php:

    <?php 
    header('Access-Control-Allow-Origin:*');

    $date = $_POST['data'];
    $cars=array("Volvo","BMW","SAAB");

    $data = array( 
    'tid' => 100, 
    'name' => $date, 
    'site' => 'www.huangyibiao.com',
    'post' =>$cars,
    );

    $response = array( 
    'code' => 200, 
    'message' => 'success for request', 
    'data' => $data,

    );

    echo json_encode($response);

    ?>

    vue:

    <div id="main">
    {{title}}
    <li v-for="li in title">{{li}}</li>
    </div>
    <script src="js/vue.min.js"></script>
    <script src="js/vue-resource.min.js"></script>
    <script>
    var app=new Vue({
    el:"#main",
    data:{
    title:"123456",
    aa:"666"
    },
    mounted:function(){
    this.click();
    },
    methods:{
    click:function(){

    Vue.http.options.emulateJSON = true;
    this.$http.post('http://localhost/php01/index.php',{'data':2}).then(function(response){
    this.title=response.body.data.post
    }, function(response){
    console.log("222");
    });
    }
    }
    })
    </script>

  • 相关阅读:
    指针
    显示和隐式转换
    C++虚函数
    字符串输出
    BP神经网络
    超像素分割
    函数putText()在图片上写文字
    compare
    十五、cookies和session的使用
    爬取腾讯社招职位信息
  • 原文地址:https://www.cnblogs.com/apolloren/p/10424536.html
Copyright © 2011-2022 走看看