Introduction
Use WXML to show values from a page’s data object. For the examples below, place the markup inside <page> and the JavaScript inside <script setup> in your .ink page. In a multi-file page, put the markup in the .wxml file and the default export in the matching .js file. Try one example at a time.
Data Binding
<view> {{message}} </view>
export default {
data: {
message: 'Hello, AIUI!'
}
}
Conditional Rendering
<view ink:if="{{status == 'loading'}}">Loading…</view>
<view ink:elif="{{status == 'error'}}">Could not load</view>
<view ink:else>Ready</view>
export default {
data: {
status: 'ready'
}
}
List Rendering
<view ink:for="{{array}}"> {{item}} </view>
export default {
data: {
array: [1, 2, 3, 4, 5]
}
}
Reuse an Interface
To use the same interface in multiple places, create a custom component. A single-file interface with incremental update support can also use region updates to add content as it arrives.