export default { name: 'order', components: {}, data() { onLoad(params) { this.getData(); this.secId = 1077; }, }, async get_shopapp_ticket_list() { try { let params = { orderId: this.secId }; let res = await shopapp_ticket_list(page, 20, orderId, params); // 直接传递参数 console.log("门票列表", res); } catch (error) { this.showTip("获取列表失败"); } } 让 this.secId = 1077; 里的secId值传到 orderId:this.secId 里,为什么没传成功的呢?vue.js正确的应该想怎么写的呢?
export default { name: 'order', components: {}, data() { onLoad(params) { this.getData(); this.secId = 1077; }, }, async get_shopapp_ticket_list() { try { let params = { orderId: this.secId }; let res = await shopapp_ticket_list(page, 20, orderId, params); // 直接传递参数 console.log("门票列表", res); } catch (error) { this.showTip("获取列表失败"); } } 让 this.secId = 1077; 里的secId值传到 orderId:this.secId 里,为什么没传成功的呢?vue.js正确的应该想怎么写的呢?
export default {
name: 'order',
components: {},
data() {
onLoad(params) {
this.getData();
this.secId = 1077;
},
},
async get_shopapp_ticket_list() {
try {
let params = { orderId: this.secId };
let res = await shopapp_ticket_list(page, 20, orderId, params); // 直接传递参数
console.log("门票列表", res);
} catch (error) {
this.showTip("获取列表失败");
}
} 让 this.secId = 1077; 里的secId值传到 orderId:this.secId 里,为什么没传成功的呢?vue.js正确的应该想怎么写的呢?
用户834492313
2023年12月20日
|
浏览 148
在Vue.js中,data属性是用于存储组件的数据的。在你的代码中,this.secId应该被声明在data属性中,以便能够在整个组件中访问它。
下面是修改后的代码示例:
复制代码
export default {
name: 'order',
components: {},
data() {
return {
secId: 1077
};
},
onLoad(params) {
this.getData();
},
async get_shopapp_ticket_list() {
try {
let params = { orderId: this.secId };
let res = await shopapp_ticket_list(page, 20, orderId, params);
console.log("门票列表", res);
} catch (error) {
this.showTip("获取列表失败");
}
}
}
通过将this.secId声明在data属性中,并使用return语句返回一个对象,可以确保secId的值在整个组件中可用。这样,orderId:this.secId就能够成功接收到this.secId的值了。
我要提问
复制内容
分享给好友
AI编程问答网 免责声明:
以上内容除特别注明外均来源于网友提问,AI编程问答网回答,权益归原著者所有;
