<template>
<div
v-if="type == xxx"
></div>
//這個時候頁面加載的type是沒有值的怎么辦呢?
</template>
computed:{ type(){ return (ajax請求回來的某一個字段的值)
}
}
1 回答

狐的傳說
TA貢獻1804條經驗 獲得超3個贊
你可以先定義一個變量在data里面,然后給個默認值,ajax方法請求回來再去回寫你之前定的那個變量;然后計算屬性type再來根據(jù)你定義的那個變量來就行了。
<template> <div v-if="type == xxx" ></div> //這個時候頁面加載的type是沒有值的怎么辦呢?</template>data(){ return { type1: '',(ajax請求回來的某一個字段的值) } }, computed:{type(){ return this.type1} }
添加回答
舉報
0/150
提交
取消