Debug a component
<Component name="Test"
var.counter = "{1}"
>
<DataSource
id="userData"
url="/api/user_data"
/>
<script>
// can customize here
function debug(msg, data) {
console.log(msg, data)
};
</script>
<Text>Method 1: JSON.stringify with preserveLinebreaks</Text>
<Text preserveLinebreaks="true">
{JSON.stringify(userData.value, null, 2)}
</Text>
<Text>Method 2: Console.log in handler</Text>
<Button
label="Log to console"
onClick="console.log(userData);console.log(userData.value)"
/>
<Text>Method 3: Use Fragment and custom debug function to watch changes</Text>
<Fragment when="{debug('counter', counter)}" />
<Button
label="Update counter"
onClick="{counter++}"
/>
</Component>
<Component name="Test"
var.counter = "{1}"
>
<DataSource
id="userData"
url="/api/user_data"
/>
<script>
// can customize here
function debug(msg, data) {
console.log(msg, data)
};
</script>
<Text>Method 1: JSON.stringify with preserveLinebreaks</Text>
<Text preserveLinebreaks="true">
{JSON.stringify(userData.value, null, 2)}
</Text>
<Text>Method 2: Console.log in handler</Text>
<Button
label="Log to console"
onClick="console.log(userData);console.log(userData.value)"
/>
<Text>Method 3: Use Fragment and custom debug function to watch changes</Text>
<Fragment when="{debug('counter', counter)}" />
<Button
label="Update counter"
onClick="{counter++}"
/>
</Component>