- // 数据
- data() {
- return {
- obj:null,
- }
- }
- // 异步调用数据
- getdetails(){
- this.axios.get("api/lottery/query",{params:{
- key:this.key,
- lottery_id:this.id
- }})
- .then(res=>{
- this.obj=res.data.result
- })
- }
- // 页面
- <h2>{{obj.lottery_name}}</h2>
- <div style="color:red"> 中奖号码:{{obj.lottery_res}}</div>
- <div > 开奖日期:{{obj.lottery_date}} 兑奖截止日期:{{obj.lottery_date}}</div>
- <div > 本期销售额:{{obj.lottery_sale_amount}}</div>
- <div > 奖池:{{obj.lottery_pool_amount}}</div>
问题就是 数据显示正确, 但是会报 lottery_name 为 undifined , 我就想请问下 有没有什么好的方法来解决这个问题.
除了设置默认值, 和判断的方法, 有没有更偷懒一点的方式
来源: http://www.qdfuns.com/article/30937/83cd079b3cf6d6913e9db540d214e086.html