AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
升级至3.0问题汇总 一、 ``` VM2090:1 TypeError: Cannot read property '__wxWebviewId__' of undefined at n.value (VM2097 WAService.js:2) at n.p.<computed> [as in] (VM2097 WAService.js:2) at Index.componentDidMount (Content.js:21) at vendors.js:19732 at errorCatcher (vendors.js:19602) at vendors.js:19731 at Array.forEach (<anonymous>) at flushMount (vendors.js:19727) at updateComponent (vendors.js:19837) at reRenderComponent (vendors.js:19765) ``` 看问题是Content文件内容有错误,获取内容的高宽出现问题了 ``` componentDidMount() { const that = this; const query = Taro.createSelectorQuery().in(this.$scope); query.select('.details').boundingClientRect(res \=> { that.setState({ width: res.width }); }).exec(); } ``` 原因是taro升级之后更换了写法,更改为一下写法,可正常运行 ``` const query \= Taro.createSelectorQuery() query.select('#the-id').boundingClientRect() query.selectViewport().scrollOffset() query.exec(function(res){ res\[0\].top // #the-id节点的上边界坐标 res\[1\].scrollTop // 显示区域的竖直滚动位置 }) ``` 二、 项目使用的是react + mobx 订单的store未定义在全局的store文件夹下面,而是放在了order的组件同级目录,导致获取不到store 升级之前是正常获取的 ``` MobX injector: Store 'order' is not available! Make sure it is provided by some Provider;at "pages/orders/order/index" page lifeCycleMethod onLoad function Error: MobX injector: Store 'order' is not available! Make sure it is provided by some Provider ``` 仔细看一下引入的mobx ``` import { observer, inject, } from '@tarojs/mobx' ``` taro3.0更改了编译模式,不再使用模板编译,所以需要直接引入mobx-react ``` import { observer, inject, } from 'mobx-react' ``` 三、所有组件ScrollView、Image等必须从@tarojs/components声明,否则会报错 3.0之前可以不用引入,直接运行