关于setData()之后数据渲染的问题
好难受,这两天也出现这个问题,求解决,求帮助!!!!!!都是同胞,求救,当点击按钮setData的时候,input已经填入的信息被清空,并且我setData的数据跟input里面的一点关系都没有,在开发者工具0.21.201800中,基础库版本1.43以上,编译之前是好的,如果编译之后会出现在form表单中,点击按钮,注意不是提交form表单,再强调一边不是提交form表单,是为了进行某些操作,执行setData()之后input的内容会被清空的问题,并且setData()里面并没有与input有任何相关的数据联系!!!!就是会被清空,而且不是一个input,是所有input会被清空
3 回复
<!--index.wxml会引用下面的xml--> < import src = "/pages/common/proto_template.wxml" /> < view class = "container" > < view class = "demoAll" > <!--表单信息--> < form > < block wx:for = "{{demo}}" wx:key = "{{index}}" > < template is = "{{item.type}}" data = "{{...demo[index]}}" /> </ block > < button class = "addBtn" bindtap = "add" >添加</ button > </ form > <!--弹出icon--> < view class = "group" bindtap = "close" wx:if = "{{show}}" > < icon type = "cancel" size = "40" /> </ view > </ view > </ view > <!-- 这里是被引用的 --> < template name = "digit" > < view > < input placeholder-class = "input-placeholder" name = "{{msg}}" value = "{{msg}}" type = "text" maxlength = "100" /> </ view > </ template > |
//js代码 var app = getApp() Page({ data: { demo: [ {name: "你好" ,placeholder: "啊哈哈哈哈" ,type: "digit" ,msg: "我是input" ,index: 0}, {name: "我不好" ,placeholder: "就是很难受" ,type: "digit" ,msg: "这里有" ,index: 1}, {name: "为什么" ,placeholder: "就是很难受啊啊啊" ,type: "digit" ,msg: "BUG" ,index: 2} ], show: false }, add: function () { var _self = this _self.setData({ "show" : true }) }, close: function () { var _self = this _self.setData({ "show" : false }) }, onLoad: function () { app.getUserInfo( function (userInfo){ }) } }) |