个人案例
青蛙报告
一款面向个人和中小企业的记录工作日志的工具
写报告扫码体验
我碰到和你一样的问题,首先我想说这是官方的一个Bug. 理想的 editor,应该支持 model:content 的语法实现双向绑定,而不是让开发者使用底层API setContents。其次,即便使用 setContents, 也应该是静默的设置内容,而不携带副作用,比如这个自动聚焦问题。 目前我的解决方案是:wx.pageScrollTo 将页面滚动到目标位置,这绝对不是好办法,但目前将就吧。注意这个方法的两种方式,一种使用 selector,一种使用scrollTop,经过试验,我的项目中前者有效(需要设置一个目标定位元素)。 等待官方回复吧,虽然基本没戏。
radio-group 与 editor 数据绑定渲染后会自动焦点,怎么取消焦点?我是使用radio-group组件,绑定数据至editor渲染数据,editor会自动焦点,且弹出键盘。 现在的问题就是会自动焦点和弹出键盘, 怎么取消掉。 <li wx:for="{{diseaseDepot}}"> <radio-group bindchange="radioChangeB"> <label class="weui-cell weui-check__label" wx:key="{{item.value}}"> <view class="weui-cell__hd"> <radio style="transform: scale(0.75)" value="{{item.title}}" checked="{{item.checked}}"/> </view> <view class="weui-cell__bd">{{item.title}}</view> </label> </radio-group> </li> // 单选内容后,数据渲染入editor, 但是默认会焦点此处, 如何取消焦点和键盘 <editor id="editorB" class="ql-container" placeholder="{{placeholder}}" showImgSize showImgToolbar showImgResize bindstatuschange="onStatusChange" read-only="{{readOnly}}" bindready="onEditorReady"> </editor> // 单选事件 radioChangeB(e) { this.data.diseaseDepot.forEach(item => { let p = item; if(p.title == e.detail.value){ let vstar = [1] p.checked = true vstar[0] = p.title vstar[1] = p.content this.onEditorReadyB(vstar[1]) this.setData({ checkedDiseaseBy: vstar }) }else{ p.checked = false } }) // html渲染至editor 组件 onEditorReadyB(vhtml) { const that = this wx.createSelectorQuery().select('#editorB').context(function (res) { if(!res) return that.editorCtx = res.context res.context.setContents({ html: vhtml, focus: false }) }).exec() },
2022-05-29