Component({ /** * 组件的属性列表 */ properties: { questionList:{ type:Array }, currentTab:{ type:Number }, currentQuestion:{ type:String } }, /** * 组件的初始数据 */ data: { answerInput:'' }, /** * 组件的方法列表 */ methods: { clearInput(){ this.setData({ answerInput:'' }) }, handleInput(e){ this.setData({ answerInput:e.detail.value }) }, openInput(e){ if(this.data.currentQuestion != e.currentTarget.dataset.index){ this.setData({ answerInput:'' }) } this.triggerEvent("changeCurrentQuestion",e.currentTarget.dataset.index); }, submitAnswer(e){ if(this.data.answerInput===''){ wx.showToast({ title: '请输入回答', icon:"none" }) return false } this.triggerEvent("submitAnswer",{id:e.currentTarget.dataset.questionid,answer:this.data.answerInput}); }, changeCollapse(e){ this.triggerEvent("changeCollapse",e); }, } })