<script>
export default {
   data(){
       return{    
          textArr:[ 
              {name:0,value:'十'},            
              {name:1,value:'一'},
              {name:2,value:'二'},
              {name:3,value:'三'},
              {name:4,value:'四'},
              {name:5,value:'五'},
              {name:6,value:'六'},
              {name:7,value:'七'},
              {name:8,value:'八'},
              {name:9,value:'九'}
          ]
       }
   },
   mounted(){   
      let text = this.numText(123465);
          console.log(text);
   },
   methods:{      
      //数字转中文
      numText(num){
         var numArr = num.toString().split('');
         var that = this;            
         var result  = []; 
         numArr.forEach(res=>{
             that.textArr.forEach(item=>{                 
                if(item.name==res){ result.push(item.value) }  
             })
         })
         return result.join('');
      },   
   }
}

 

Logo

前往低代码交流专区

更多推荐