1-1 导入Taro模块
//index.vue
import Taro from '@tarojs/taro'
1-2 Taro request 请求对应http渲染页面
//index.vue
<template>
<view class="index">
<!-- <text>{{ msg }}</text> -->
<view v-for="item of movies" :key="item.id">
<image :src="item.pic" alt=""></image>
{{item.title}}
</view>
</view>
</template>
<script>
import './index.scss';
import Taro from '@tarojs/taro'
export default {
data () {
return {
msg: 'Hello world!',
movies:[]
}
},
mounted () {
Taro.request({
url: 'http://120.55.54.252:6060/api/movie/top250',
data: {
foo: 'foo',
bar: 10,
movies:[]
},
header: {
'content-type': 'application/json'
}
}).then(res =>
this.movies = res.data.res
)
}
}
</script>