Custom filter function

Example of application scenario: If the display content of a certain cell on the page is required to be "only yes", "no" and "other", and the data passed or required to be passed by the backend corresponds to " 0", "1", "2", at this time, you need to use the filter function to filter and display.

The function definition is as follows:

convertToText(value) {

            const valueMap = {

                0: 'Yes',

                1: 'No',

                2: 'Other'

            };

            return valueMap[value] || value;

        }

Page application:

 <template slot="read">{ { flowModel.fete | convertToText }}</template>

Note: The filter() method creates a new array, and the elements in the new array are checked by checking the conditions in the specified array

All elements, without changing the original array.

Guess you like

Origin blog.csdn.net/Anna_lhy/article/details/103181415