globaldata的用法
写在全局变量app.vue中globalData:{num:’’,//商品数量name:’’,//合伙人名称phone:’’,//合伙人电话id:’’,//合伙人idcategory_id:’’,//商品idarr:{},//地址show:true,Hide:false}然后在页面中使用哪个就调用哪个onLoad(opctions) {// 获取到全局中的地址let a = getApp().gl
写在全局变量app.vue中
globalData:{
num:’’,//商品数量
name:’’,//合伙人名称
phone:’’,//合伙人电话
id:’’,//合伙人id
category_id:’’,//商品id
arr:{},//地址
show:true,
Hide:false
}
然后在页面中使用哪个就调用哪个
onLoad(opctions) {
// 获取到全局中的地址
let a = getApp().globalData.arr
console.log(a);
this.site = a
console.log(this.site);
this.name = getApp().globalData.name
this.hide = getApp().globalData.show
},
打印与功能实现
immediately(i){
console.log(i);
console.log(getApp().globalData.category_id);
console.log(i.score);
console.log(this.value);
console.log(getApp().globalData.id);
console.log(parseFloat(i.price)*parseFloat(this.value));
console.log(getApp().globalData.name);
console.log(getApp().globalData.phone);
uni.request({
url:"",
data:{
userid:21,
password:123456,
shopid:getApp().globalData.category_id,
score:300,
num:this.value,
pid:getApp().globalData.id,
num_score:parseFloat(i.price)*parseFloat(this.value),
phone:119,
account:‘小明’,
pid_name:getApp().globalData.name,
pid_phone:getApp().globalData.phone,
type:2
},
success: (res) => {
console.log(res);
}
})
},
更多推荐
所有评论(0)