一.在终端里面输入:

  1. npm i axios-jsonp-pro -S

二.发送http请求

  1. <script>
  2. import axios from 'axios-jsonp-pro';
  3. export default{
  4. mounted(){
  5. var url = "https://douban.uieee.com/v2/movie/in_theaters";
  6. axios.jsonp(url).then(res=>{
  7. this.movies = res.subjects;
  8. })
  9. }
  10. }
  11. </script>

三.调用

  1. <script>
  2. export default{
  3. data(){
  4. return{
  5. movies:[]
  6. };
  7. }
  8. }
  9. </script>

四.数据渲染

  1. //数据渲染
  2. <template>
  3. <div id="app">
  4. <div class="item" v-for="item of movies" :key="item.id">
  5. <p>{{item.title}}</p>
  6. <!-- vue中属性要使用变量要在前面加: -->
  7. <img :src="item.images.small" alt="">
  8. </div>
  9. </div>
  10. </template>