微信小程序动态增加组件、删除组件

微信小程序、按钮、动态、添加、组件、控件

< view class= "page__bd">
< view class= "weui-article">
< button bindtap= "insert">增加课程 </ button >
< button bindtap= "delBind">删除课程 </ button >
< form bindsubmit= "formSubmit" bindreset= "formReset">
< view wx:for= "{{checkbox}}" class= "con">

< input name= "courseName{{index}}" class= "input-address" maxlength= "50" placeholder= "课程名称(必填):" / >
< input name= "techerName{{index}}" class= "input-address" maxlength= "10" placeholder= "老师名称(必填):" / >

< radio-group name= "radio{{index}}">
< label >
< radio value= "A" / >A </ label >
< label >
< radio value= "B" / >B </ label >
< label >
< radio value= "C" / >C </ label >
</ radio-group >
</ view >
< button class= "weui-btn" type= "primary" formType= "submit">提交 </ button >
</ form >
</ view >
</ view >

Page({
data: {
checkbox: [],
array: [ 'A', 'B', 'C'],
isReview: false,
isVerify: false,
},
insert: function () {
var cb = this.data.checkbox;
console.log(cb);
cb.push( this.data.checkbox.length);
this.setData({
checkbox: cb
});
},
delBind: function () {
var cb = this.data.checkbox;
console.log(cb);
cb.pop( this.data.checkbox.length);
this.setData({
checkbox: cb
});
},
})



  • 3
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值