render 渲染iview input框和checkbox多选框

本文介绍了如何使用JavaScript来渲染iView框架中的input输入框和checkbox多选框,并实现数据的双向绑定。通过示例代码展示了具体实现过程。

1.渲染input框实现数据双向绑定

js:

h("i-input", {
                              style: {
                                width: "300px",
                                autofocus: true,
                                display: "flex",
                                "margin-top": "10px"
                              },
                              props: {
                                placeholder: "請輸入分組名稱",
                                // 使用value绑定数据而不是'v-model'
                                value:this.group_input,
                                clearable:true,
                              },
                              on:{
                                  'on-blur':(val)=>{
                                      this.group_input=val.target.value,
                                      console.log(this.group_input,"yyyyyyyy")
                                  }
                              }
                            }),

2.渲染checkbox实现数据双向绑定

js:

 [
                                                h(
                                                  "checkbox-group",
                                                  {
                                                    props: {
                                                        value: this.checkboxValue
                                                      },
                                                      on:{
                                                          'on-change':(val)=>{
                                                              this.checkboxValue=val;
                                                              console.log(val,11)
                                                          }
                                                      }
                                                  },
                                                  [ 
                                                    h("checkbox", {
                                                      props: {
                                                        label: "人力總數"
                                                      },
                                                      style: {
                                                        display: "flex"
                                                      },
                                                    }),
                                                    h("checkbox", {
                                                      props: {
                                                        label: "新進人力"
                                                      },
                                                      style: {
                                                        display: "flex"
                                                      }
                                                    }),
                                                    h("checkbox", {
                                                      props: {
                                                        label: "流失人力"
                                                      },
                                                      style: {
                                                        display: "flex"
                                                      }
                                                    }),
                                                    h("checkbox", {
                                                      props: {
                                                        label: "出勤"
                                                      },
                                                      style: {
                                                        display: "flex"
                                                      }
                                                    }),
                                                    h("checkbox", {
                                                      props: {
                                                        label: "直接人力"
                                                      },
                                                      style: {
                                                        display: "flex"
                                                      }
                                                    }),
                                                    h("checkbox", {
                                                      props: {
                                                        label: "間接人力"
                                                      },
                                                      style: {
                                                        display: "flex"
                                                      }
                                                    })
                                                  ]
                                                )
                                              ]

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值