Skip to content

attribute 绑定

常见示例

xml
<image src="{{imgSrc}}" />
js
Page({
  data: {
    imgSrc: 'https://example.com/image.png',
  },
})

绑定 class 属性

xml
<view class="{{isActive ? 'active' : 'inactive'}}">Hello</view>
js
Page({
  data: {
    isActive: true,
  },
})

绑定 style 属性

xml
<view style="color: {{textColor}}; font-size: {{fontSize}}px;">Hello</view>
js
Page({
  data: {
    textColor: 'red',
    fontSize: 20,
  },
})

基于 MIT 许可发布