vue的filter如何應用

這篇文章主要介紹“vue的filter如何應用”的相關知識,小編通過實際案例向大家展示操作過程,操作方法簡單快捷,實用性強,希望這篇“vue的filter如何應用”文章能幫助大家解決問題。

創(chuàng)新互聯(lián)自2013年創(chuàng)立以來,是專業(yè)互聯(lián)網(wǎng)技術服務公司,擁有項目成都網(wǎng)站建設、網(wǎng)站建設網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元濰城做網(wǎng)站,已為上家服務,為濰城各地企業(yè)和個人服務,聯(lián)系電話:13518219792

filter一般用于過濾某些值,比如我這個字段是空,可是我想在前端顯示“–”,就可以使用到它了。

最近碰到一個需求就是要給某些字段可以設置權限去以其他形式顯示,比如以“***”顯示需要隱藏的金額。

1.獲取金額權限

2.通過filter過濾滿足條件的字段

3.返回隱藏的樣式

看代碼:

//其他的看,看我標注的就可以了
//scope.row 獲取當前行
<template slot-scope="scope">
            <template v-if="item.formType == 'label'">
              <el-button
                v-if="item.link!=undefined"
                type="text" size="small" @click="handleColumnClick(item.link,scope.row)">
                //filter一般不用的過濾用|
                //showLabelValue就不寫出來了
                //方法一個參數(shù)對應的filter是兩個參數(shù)
                //第一個是前一列返回的值
                //第N-1個是你想傳的值
                {{ scope.row | showLabelValue(item) | canViewAmount(canViewAmount,xtType,item) }}
              </el-button>
              <template v-else>
                {{ scope.row | showLabelValue(item) | canViewAmount(canViewAmount,xtType,item) }}
              </template>
            </template>
</template>
export default {
 filters: {
 //row就是scope.row返回的數(shù)據(jù)
 showLabelValue(row,item){
 return 'value'
 }
 //value值, canView權限, xtType哪個頁面, item列表數(shù)據(jù)
 //如果showLabelValue返回的是value,對應的canViewAmount參數(shù)的value就是‘value'
    canViewAmount(value, canView, xtType, item) {
    //滿足條件用“***”顯示(只是顯示),保存到數(shù)據(jù)庫還是原列表的內容
      if (!canView && xtType == 'salesOrder') {
        if (item.field == 'priceNoTax' || item.field == 'amountNoTax' || item.field == 'price' || item.field == 'amount') {
          return '***'
        }
      }
      if (!canView && xtType == 'project') {
        if (item.field == 'amount' || item.field == 'amountNoTax') {
          return '***'
        }
      }
      return value
    }
  },

關于“vue的filter如何應用”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關的知識,可以關注創(chuàng)新互聯(lián)行業(yè)資訊頻道,小編每天都會為大家更新不同的知識點。

本文名稱:vue的filter如何應用
URL網(wǎng)址:http://bm7419.com/article0/jcchoo.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、外貿網(wǎng)站建設、面包屑導航服務器托管、App開發(fā)營銷型網(wǎng)站建設

廣告

聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站優(yōu)化排名