我们在vue,数据很多事异步获取来的,如果在template直接使用,会报错,undefined。
因为先渲染后得到的数据,那如何才能不报错呢?
computed!!!
举个例子
index.vue
忽略坑人的传参方式。。。
created(){
this.init()
this.axios.post('/wanwei/appserver/eqinfo/eqbaseinfo?reqjson={"eq_code":"bjte1w03011sf001sbqdgpxtgykg001"}').then((res) => {
this.$nexttick(()=>{
this.$store.state.retdata = res.data.retdata
})
})
},
在创建时获取数据,将其存入store
加入页面只能这样写
equip.vue
规格信息
设备惯用名
{ {equipdata.convent_eq}}
设备名称
{ {equipdata.eq_name}}
规格型号
{ {equipdata.mod