返回值,参考下图处理一下 /** * 替换换行 */ replaceHH: function(str) { return str.replace(/<br>/g, '\n'); } [图片]
text组件/n换行的问题前台如果写死的\n的字符串放到text中是可以实现换行 js: [代码]this[代码][代码].setData({[代码][代码] [代码][代码]content:[代码][代码]'你好\n你好'[代码][代码]})[代码] html: [代码]<[代码][代码]text[代码][代码]>{{content}}</[代码][代码]text[代码][代码]>[代码]结果图: [图片] 但如果是请求接口后端返回的数据 [图片] 接口没问题,但放到data里面后会被自动转掉,而且没有一个参数能控制这个text组件让他步自动转义 [图片] 效果图: [图片] 显示的不再是换行。。。 总结: 后台加载的数据里添加了\n,但是并没有换行,自己前台写死的字符串的\n是有换行效果的。
2022-02-22真机模拟或者体验版的时候可以加一个这个force-use-old-canvas="true" 预览调试的时候这个会报错,去掉,设置false是没有用的哦 <ec-canvas id="mychart" canvas-id="mychart-bar" ec="{{ ec }}" force-use-old-canvas="true"></ec-canvas>
真机调试错误,这是什么情况?怎么定位问题?VM21:2 (in promise) MiniProgramError Cannot read property 'createView' of undefined TypeError: Cannot read property 'createView' of undefined at n.value (eval at n.call.document (http://127.0.0.1:51844/remote-debug/runtime.js?devtools_ignore=true:1:11339), <anonymous>:2:1064980) at n.value (eval at n.call.document (http://127.0.0.1:51844/remote-debug/runtime.js?devtools_ignore=true:1:11339), <anonymous>:2:757375) at t (eval at n.call.document (http://127.0.0.1:51844/remote-debug/runtime.js?devtools_ignore=true:1:11339), <anonymous>:2:757542) at n.value (eval at n.call.document (http://127.0.0.1:51844/remote-debug/runtime.js?devtools_ignore=true:1:11339), <anonymous>:2:757631) at eval (eval at n.call.document (http://127.0.0.1:51844/remote-debug/runtime.js?devtools_ignore=true:1:11339), <anonymous>:2:1300784) at new Promise (<anonymous>) at pu (eval at n.call.document (http://127.0.0.1:51844/remote-debug/runtime.js?devtools_ignore=true:1:11339), <anonymous>:2:1300746) at eval (eval at n.call.document (http://127.0.0.1:51844/remote-debug/runtime.js?devtools_ignore=true:1:11339), <anonymous>:2:1302216) at Array.forEach (<anonymous>) at r (eval at n.call.document (http://127.0.0.1:51844/remote-debug/runtime.js?devtools_ignore=true:1:11339), <anonymous>:2:1302194)
2021-04-07真机模拟或者体验版的时候可以加一个这个force-use-old-canvas="true" 预览调试的时候这个会报错,去掉,设置false是没有用的哦 <ec-canvas id="mychart" canvas-id="mychart-bar" ec="{{ ec }}" force-use-old-canvas="true"></ec-canvas>
canvas 2d android真机property 'createView' undefinedVM21:2 (in promise) MiniProgramError Cannot read property 'createView' of undefined TypeError: Cannot read property 'createView' of undefined at t.value (eval at n.call.document (http://127.0.0.1:40184/remote-debug/runtime.js?devtools_ignore=true:1:11339), <anonymous>:2:2237101) at t.value (eval at n.call.document (http://127.0.0.1:40184/remote-debug/runtime.js?devtools_ignore=true:1:11339), <anonymous>:2:1868186) at A (eval at n.call.document (http://127.0.0.1:40184/remote-debug/runtime.js?devtools_ignore=true:1:11339), <anonymous>:2:1868352) at t.value (eval at n.call.document (http://127.0.0.1:40184/remote-debug/runtime.js?devtools_ignore=true:1:11339), <anonymous>:2:1868463) at eval (eval at n.call.document (http://127.0.0.1:40184/remote-debug/runtime.js?devtools_ignore=true:1:11339), <anonymous>:2:2566063) at new Promise (<anonymous>) at cc (eval at n.call.document (http://127.0.0.1:40184/remote-debug/runtime.js?devtools_ignore=true:1:11339), <anonymous>:2:2566025) at eval (eval at n.call.document (http://127.0.0.1:40184/remote-debug/runtime.js?devtools_ignore=true:1:11339), <anonymous>:2:2567487) at Array.forEach (<anonymous>) at n (eval at n.call.document (http://127.0.0.1:40184/remote-debug/runtime.js?devtools_ignore=true:1:11339), <anonymous>:2:2567465) errorReport @ VM21:2 runtime.js?devtools_ignore=true:1 [Violation] 'message' handler took 156ms
2021-04-07