HarmonyOS 鸿蒙Next checkout的selet怎么双向绑定
HarmonyOS 鸿蒙Next checkout的selet怎么双向绑定
checkout中的select如何用双向绑定啊
文档中说支持使用$$符号,但是怎么用啊
import { SelectOptions } from ‘@kit.ArkUI’
@Styles function card(){
.width(‘90%’)
.backgroundColor(Color.White)
.padding(20)
.borderRadius(15)
.shadow({radius: 6, color: ‘#1F000000’, offsetX: 2, offsetY: 4})
}
class taskItem{
static id: number = 1
// 任务名称
name: string = 任务${taskItem.id++}
finish:boolean=false
}
class taskState{
finish:number = 0
all:number = 0
}
@Entry
@Component
struct Index {
@State tasks:Array<taskItem> = []
@State taskState:taskState = new taskState()
build() {
Column({space:10}) {
staticTaskList({finish:this.taskState.finish,all:this.taskState.all})
Button(‘增加任务’).onClick((event: ClickEvent) => {
this.tasks.push(new taskItem())
this.taskState.all = this.tasks.length
})
List({space:10}){
ForEach(this.tasks,(item:taskItem,index)=>{
ListItem(){
Row(){
Text(item.name)
Checkbox()
.select($$this.tasks[index].finish)
.shape(CheckBoxShape.ROUNDED_SQUARE)
}
.justifyContent(FlexAlign.SpaceBetween)
.card()
.onClick(()=>{
this.tasks[index].finish = !this.tasks[index].finish
this.taskState.finish = this.tasks.filter((item)=>item.finish).length
console.log(this.taskState.finish.toFixed())
})
}
.align(Alignment.Center)
.width(“100%”)
})
}
}
.padding({top:10,bottom:10})
.width(‘100%’)
.height(‘100%’)
.backgroundColor(’#F1F2F3’)
}
}
@Component
struct staticTaskList{
name:string = “任务进度:”
@Prop finish:number
@Prop all:number
build() {
Row(){
Text(this.name)
.fontSize(30)
Stack(){
Progress({
value:this.finish,
total:this.all,
type:ProgressType.Ring
})
.width(100)
Row(){
Text(${<span class="hljs-keyword"><span class="hljs-keyword">this</span></span>.finish?.toFixed()}/${<span class="hljs-keyword"><span class="hljs-keyword">this</span></span>.all?.toFixed()}
)
.fontSize(24)
}
}
}
.card()
.justifyContent(FlexAlign.SpaceBetween)
}
}
<button style="position: absolute; padding: 4px 8px 0px; cursor: pointer; top: 8px; right: 8px; font-size: 14px;">复制</button>
关于HarmonyOS 鸿蒙Next checkout的selet怎么双向绑定的问题,您也可以访问:https://www.itying.com/category-93-b0.html 联系官网客服。
更多关于HarmonyOS 鸿蒙Next checkout的selet怎么双向绑定的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
更多关于HarmonyOS 鸿蒙Next checkout的selet怎么双向绑定的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
楼主解决了吗,我用复杂类型里面的布尔类型就出错不让用,楼主后面你怎么解决的啊