開發中的細節整理

1.截取某個字段,進行判斷:ary.hasOwnProperty(key); 或 obj.hasOwnProperty(key);css

2.判斷是否字段爲空。爲空時爲定值:例如判斷 :{{ mitem.eventName}} 字段是否爲空,爲空時爲顯示 盡情期待api

 

<div class="block-left" v-if="item.currentEventId === mitem.eventId" v-for="(mitem, index) in dicEvents" :key="index">
<span class="m-phase">
{{mitem.eventName}}
</span>

 

{{mitem.eventName === null || mitem.eventName === "" ? '盡情期待': mitem.eventName}}
3.獲取接口中的某個字段方法:
<div class="block-left" v-if="item.currentEventId === mitem.eventId" v-for="(mitem, index) in dicEvents" :key="index">
<span class="m-phase">
{{mitem.eventName}}
</span>
</div>
4.獲取某個接口的方法:例如:initRun接口
initRun() {
api.initRun()
.then(function (res) {
if (res.code === 200) {
this.deptList = JSON.parse(res.data)
this.dicRunTags = this.deptList.dicRunTags
this.dicEvents = this.deptList.dicEvents
// console.log(this.dicEvents)
}
}.bind(this)).catch(function (err) {
console.log(err)
})
},
created() {
this.initRun();
}
5.get和post請求接口的方法轉化方法:api.js(post方式)
getRunHeads(params) {
return fetch.fetchPost('opt/getRunHeads', params)
},index.js
// 負責人區域start
getRunHeads() {
let params = {
runId: this.$route.params.runId
};
api
.getRunHeads(params)
.then(function (res) {
if (res.code === 200) {
this.headList = JSON.parse(res.data);
}
}.bind(this)).catch(function (err) {
console.log(err)
})
},
 
6.字段沒有值時,隱藏不顯示
<tr>
<td class="m-table-mainteam" >項目主創團隊</td>
<td clas="m-table-number" >
<tr v-for="(item, index) in runCastsList" :key="index" >
<span v-if=" item.teamName!=''">{{item.teamName}}:</span>
<span v-if=" item.castName!=''"> {{item.castName}}</span>
<span v-if=" item.signName!=''">({{item.signName === null || item.signName === "" ? '無':item.signName }})</span>
<!-- <span v-if="item.castName!=''"> {{item.castName}}</span>
<span v-if="item.signName!=''">({{item.signName}})</span> -->
<!-- <span>({{item.signName === null || item.signName === "" ? '無':item.signName }})</span> -->
</tr>
</td>
</tr>
<tr >
<td class="m-table-mainteam">我方權益</td>
<td clas="m-table-number" >
<tr v-if="runRightsList.key1!=null && runRightsList.key1!=''"> 劇本版權 {{runRightsList.key1}}</tr>
<tr v-if="runRightsList.key2!=null && runRightsList.key2!=''"> 影片版權:{{runRightsList.key2}}</tr>
<tr v-if="runRightsList.key3!=null && runRightsList.key3!=''"> 新媒體版權:{{runRightsList.key3}}</tr>
<tr v-if="runRightsList.key4!=null && runRightsList.key4!=''"> 影片發行權:{{runRightsList.key4}}</tr>
<tr v-if="runRightsList.key5!=null && runRightsList.key5!=''"> 電視臺收益權:{{runRightsList.key5}}</tr>
<tr v-if="runRightsList.key6!=null && runRightsList.key6!=''"> 院線收益權:{{runRightsList.key6}}</tr>
<tr v-if="runRightsList.key7!=null && runRightsList.key7!=''"> 新媒體收益權:{{runRightsList.key7}}</tr>
<tr v-if="runRightsList.key8!=null && runRightsList.key8!=''"> 商務開發權:{{runRightsList.key8}}</tr>
<tr v-if="runRightsList.key9!=null && runRightsList.key9!=''"> 衍生品開發權:{{runRightsList.key9}}</tr>
<tr v-if="runRightsList.key10!=null && runRightsList.key10!=''"> 系列做品優先投資權:{{runRightsList.key10}}</tr>
<tr v-if="runRightsList.key11!=null && runRightsList.key11!=''"> 署名權:{{runRightsList.key11}}</tr>
<tr v-if="runRightsList.key12!=null && runRightsList.key12!=''"> 其餘權益:{{runRightsList.key12}}</tr>
</td>
</tr>
相關文章
相關標籤/搜索