In VUE, the back end returns a number, how does the front end convert it into the corresponding Chinese

The data from the background is

const list= [{ companyid: 0, description: "", id: "78a500e920364d689a44f740a69c5094", level: 2, orgCode: 11 "WWW", orgName: "products", parentId: "3 d44c95136584e638bc248c2166c2295," parentName: "Beijing temple of heaven, the hospital co., LTD. /", type: 0, userId: ", "}]Copy the code

Question:

Want to convert “level” to “level 2” display

Solutions:

Define a dictionary in data:

LevelArr: {1: "level 1", 2: "2", 3: "level 3", 4: "4", 5: "5", 6: "6", 7: "7" and 8: "8", 9: "nine grades", 10: "ten steps,"}Copy the code

call

<div>{{levelArr[list[0].level]}}</div>
Copy the code