Skip to content
On this page

Parameter passing usage examples

Vue Lim

Vue Parameter Show compile output
vue
<script setup lim>
const persons = [ {
    name: 'Jack',
    age: 18,
}, {
    name: 'Bob',
    age: 19,
} ];
const addAge = (data) => data.age += 1;
</script>
<template>
    <div v-for="item, index in persons">
        <span>{{index}}: {{item.name}} age is {{item.age}}</span>
        <button @click="addAge(item)">Add Age</button>
    </div>
</template>

React Lim

React Parameter Show compile output
jsx
function App () {
    const persons = [ {
        name: 'Jack',
        age: 18,
    }, {
        name: 'Bob',
        age: 19,
    } ];
    const addAge = (data) => data.age += 1;
    return <>
        {
            persons.map((item, index) => (
                <div>
                    <span>{index}: {item.name} age is {item.age}</span>
                    <button onClick={() => addAge(item)}>Add Age</button>
                </div>
            ))
        }
    </>;
}

LimF 2022-present