[Record] The interface obtains abstract field data, how to define the field data required for rendering

At work, the interface data returned by the backend may be numeric or English, but what is needed in the page is Chinese. You can use this method to process it.

<!-- HTML部分 -->
<div class="info">需要展示的数据:{
    
    {
    
     whichArticle }}</div>



<!-- script部分-->
get whichArticle() {
    
    
        const map = {
    
    
            1: '第一条',  // 1为接口返回的数据,'第一条'为我们希望展示的数据
            2: '第二条',
            3: '第四条',
            4: '第五条'
        };
        return map[this.blockData.articleData];  //this.blockData.articleData 为接口返回数据数组 (略)
    }

Guess you like

Origin blog.csdn.net/weixin_55005618/article/details/124190025