【2025年1月2日】关于腾讯云小程序平台更名为腾讯云超级应用服务的公告
控制台更新动态
Android SDK 更新动态
iOS SDK 更新动态
Flutter 更新动态
IDE 更新动态
基础库更新动态
<view> {{ message }} </view>
Page({data: {message: 'Hello MINA!'}})
<view id="item-{{id}}"> </view>
Page({data: {id: 0}})
<view wx:if="{{condition}}"> </view>
Page({data: {condition: true}})
true:boolean 类型的 true,代表真值。false: boolean 类型的 false,代表假值。<checkbox checked="{{false}}"> </checkbox>
{{}} 内进行简单的运算,支持的有如下几种方式:<view hidden="{{flag ? true : false}}"> Hidden </view>
<view> {{a + b}} + {{c}} + d </view>
Page({data: {a: 1,b: 2,c: 3}})
3 + 3 + d。<view wx:if="{{length > 5}}"> </view>
<view>{{"hello" + name}}</view>
Page({data:{name: 'MINA'}})
<view>{{object.key}} {{array[0]}}</view>
Page({data: {object: {key: 'Hello '},array: ['MINA']}})
<view wx:for="{{[zero, 1, 2, 3, 4]}}"> {{item}} </view>
Page({data: {zero: 0}})
[0, 1, 2, 3, 4]。<template is="objectCombine" data="{{for: a, bar: b}}"></template>
Page({data: {a: 1,b: 2}})
{for: 1, bar: 2}...来将一个对象展开<template is="objectCombine" data="{{...obj1, ...obj2, e: 5}}"></template>
Page({data: {obj1: {a: 1,b: 2},obj2: {c: 3,d: 4}}})
{a: 1, b: 2, c: 3, d: 4, e: 5}。key 和 value 相同,也可以间接地表达。<template is="objectCombine" data="{{foo, bar}}"></template>
Page({data: {foo: 'my-foo',bar: 'my-bar'}})
{foo: 'my-foo', bar:'my-bar'}。<template is="objectCombine" data="{{...obj1, ...obj2, a, c: 6}}"></template>
Page({data: {obj1: {a: 1,b: 2},obj2: {b: 3,c: 4},a: 5}})
{a: 5, b: 3, c: 6}。<view wx:for="{{[1,2,3]}} ">{{item}}</view>
<view wx:for="{{[1,2,3] + ' '}}">{{item}}</view>
文档反馈