vue使用三元運算子過濾後臺資料中的number變成String
阿新 • • 發佈:2018-12-29
<template> <div id="app" style="width:300px;height:700px;border:1px solid red;"> <p v-for="obj in datascore">{{changeType(obj.job)}}</p> </div> </template> <script> export default { name: 'app', data () { return { datascore:[ {name:"蘇罡",job:1}, {name:"趙寧",job:2}, {name:"徐志斌",job:3}, {name:"田彭偉",job:4}, {name:"程鵬飛",job:5}, ], }; }, components: { }, methods: { changeType(str){ return str==1? "前端開發":str==2?'java開發':str==3?"資料庫":str==4?"職業經理":'石家莊扛把子'; } }, } </script>