element中根據後臺返回的值顯示不同的標籤

       <el-table :data="rightList" border stripe>
        <el-table-column type="index"></el-table-column>
        <el-table-column label="權限名稱" prop="authName"></el-table-column>
        <el-table-column label="路徑" prop="path"></el-table-column>
        <el-table-column label="權限等級" prop="level">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.level === '0'">一級</el-tag>
            <el-tag type="success" v-else-if="scope.row.level === '1'">二級</el-tag>
            <el-tag type="warning" v-else>三級</el-tag>
          </template>
        </el-table-column>
      </el-table>
<script>
export default {
  name: 'Rights',
  mixins: [],
  components: {},
  props: {},
  data () {
    return {
      // 權限列表
      rightList: []

    }
  },
  watch: {},
  computed: {},
  methods: {
    // 獲取所有的權限
    async getRightsList () {
      const { data: res } = await this.$http.get('rights/list')
      if (res.meta.status !== 200) {
        return this.$message.error('獲取權限列表失敗!')
      }
      this.rightList = res.data
      console.log(this.rightList)
    }
  },
  created () {
    // 獲取所有的權限
    this.getRightsList()
  },
  mounted () { }
}
</script>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章