Vuido
  • About Vuido
  • Introduction
  • Installation
    • Manual Configuration
    • Production Builds
  • Usage
    • Window Template
    • Script Section
    • Interpolations
    • Computed Properties
    • Conditionals and Loops
    • Handling User Input
    • Managing Windows
    • Displaying Dialogs
    • Custom Components
    • Using libui Classes
    • Common Attributes
  • Packaging
  • Built-in Components
    • Window
    • Containers
      • Box
      • Form
      • Group
      • Tab
    • Widgets
      • Area
        • AreaGroup
        • AreaPath
        • AreaText
      • Button
      • Checkbox
      • ColorButton
      • Combobox
      • DatePicker
      • DateTimePicker
      • DropdownList
      • FontButton
      • ProgressBar
      • RadioButtons
      • Separator
      • Slider
      • Spinbox
      • Text
      • TextArea
      • TextInput
      • TimePicker
Powered by GitBook
On this page
  • Conditional Rendering
  • List Rendering
  1. Usage

Conditionals and Loops

Conditional Rendering

To render a widget or container only under certain conditions, you can use the v-if directive:

<template>
  <Window title="Example" width="400" height="100" margined>
    <Box padded>
      <Text>Welcome to your Vuido application!</Text>
      <Text v-if="seen">You can see this</Text>
    </Box>
  </Window>
</template>

<script>
export default {
  data() {
    return {
      seen: true
    };
  }
}
</script>

In this example, both Text widgets are displayed because the condition evaluates to true. When the value of the seen property is changed to false, the second Text widget is removed from the window.

You can use v-else-if and v-else directives to create conditions with multiple alternatives:

<Button v-if="mode == 'button'">This is a button</Button>
<Checkbox v-else-if="mode == 'checkbox'">This is a checkbox</Checkbox>
<Text v-else>This is something else</Text>

List Rendering

To render multiple instances of the same component, you can use the v-for directive:

<template>
  <Window title="Example" width="400" height="100" margined>
    <Box padded>
      <Text v-for="item in items">- {{ item }}</Text>
    </Box>
  </Window>
</template>

<script>
export default {
  data() {
    return {
      items: [ 'apples', 'oranges', 'bananas' ]
    };
  }
}
</script>

In this example, three Text widgets are rendered, one for each element of the items array. When an item is added or removed from this array, corresponding Text widgets are automatically added or removed.

It's recommended to provide a unique key attribute for each item. This way, the state of widgets will be preserved when array items are reordered.

PreviousComputed PropertiesNextHandling User Input

Last updated 6 years ago

Note that conditional directives destroy and create the widgets whenever the condition changes. To temporarily hide a widget without destroying it, you can use the attribute.

See also in the Vue.js documentation for more details.

See also in the Vue.js documentation for more details.

Conditional Rendering
List Rendering
visible