废话不多说了,上代码

<template>
  <ul>
    <li v-for = "(item, index) in arrs" v-bind:key = 'index'>
        <span>{{dataAmand(item.title)}}</span>
    </li>
  </ul>
</template>
<script>
export default {
  data () {
    return {
      arr: [
        {title: '奥利维亚'},
        {title: '丽娜.因巴斯'},
        {title: '希尔瓦娜斯'}
      ]
    }
  },
  computed: {
    dataAmand () {
       return function (value) {
         return this.countNum(value, 4)
       }
    }
  },
  methods: {
    countNum (v, l) {
      return v.length > l ? v.substring(0, l) : v
    }
  }
}
</script>
Logo

前往低代码交流专区

更多推荐