本文环境:windows7、vue2.9.6,该方法适用于所有品牌的电脑。
vue.js渲染背景图的方法:
带参数传值
本地美食
美食
美食 | 美食图片 | 美食价格 |
{{i.name}} | {{i.price}} |
export default {
name: "foot",
data: function () {
return {
footlist: [] //初始化列表
}
},
mounted() {
var aa = this.$route.params.id; //获取上个页面带过来的参数
this.axios({
url: '/api/app/foot/', //api 是跨越时设置的 app是路由分发 foot是后端的接口
data: {aa:aa}, //向后端传递参数
method: 'post' //post方式
}).then((res) => {
if (res.data.code == 200) { // code == 200时
this.footlist = res.data.message; // 初始化赋值
console.log(res)
}
})
}
}