[Vuejs]-How can I bind dynamic fields from server with vuejs

2๐Ÿ‘

<script>
    module.exports = {
        data: function () {
            return {
                filedNameFromServer: ['filed1', 'filed2','filed3'],
                dataFromServer: {
                    filed1: 'value1',
                    filed2: 'value2',
                    filed3: 'value3'
                }
            }
        },
        methods: {

        }
    }
</script>

HTML:

<template>
    <ul>
        <li v-for="filedName in filedNameFromServer">
          {{ dataFromServer[filedName] }}
        </li>
    </ul>
    //which I want after compile
    <ul>
        <li>value1</li>
        <li>value2</li>
        <li>value3</li>
    </ul>
</template>

PS: should filed be field, or is your data actually about files / filing?

๐Ÿ‘คLinus Borg

Leave a comment