You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
问题描述
[问题描述:站在其它人的角度尽可能清晰地、简洁地把问题描述清楚]
taro cli 1.2.22升级到1.2.26后,原生小程序先运行taro convert,然后运行 npm run dev:weapp后,在原来小程序onLoad函数里面如果存在参数op,想获得op里面的值会报错,Cannot read property 'id' of undefined 复现步骤
[复现问题的步骤]
1.taro convert
2.npm run dev:weapp
3.运行编译后的代码
[或者可以直接贴源代码,能贴文字就不要截图]
// 这里可以贴代码小程序源码Page({data: {},onLoad: function(op){letid=op.idconsole.log(id)}})taroconvert后的代码:import{Block}from'@tarojs/components'importTarofrom'@tarojs/taro'importwithWeappfrom'@tarojs/with-weapp'
@withWeapp('Page')class_CextendsTaro.Component{state={}componentWillMount=op=>{letid=op.idconsole.log(id)}config={}render(){return<Block>123</Block>}}/** * Created by ryan on 2019/4/16. */exportdefault_Cnpmrun dev:weapp后的代码"use strict";Object.defineProperty(exports,"__esModule",{value: true});var_createClass=function(){functiondefineProperties(target,props){for(vari=0;i<props.length;i++){vardescriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"indescriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}returnfunction(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);returnConstructor;};}();var_get=functionget(object,property,receiver){if(object===null)object=Function.prototype;vardesc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){varparent=Object.getPrototypeOf(object);if(parent===null){returnundefined;}else{returnget(parent,property,receiver);}}elseif("value"indesc){returndesc.value;}else{vargetter=desc.get;if(getter===undefined){returnundefined;}returngetter.call(receiver);}};var_dec,_class,_class2,_temp2;var_index=require("../../../npm/@tarojs/taro-weapp/index.js");var_index2=_interopRequireDefault(_index);var_index3=require("../../../npm/@tarojs/with-weapp/index.js");var_index4=_interopRequireDefault(_index3);function_interopRequireDefault(obj){returnobj&&obj.__esModule ? obj : {default: obj};}function_classCallCheck(instance,Constructor){if(!(instanceinstanceofConstructor)){thrownewTypeError("Cannot call a class as a function");}}function_possibleConstructorReturn(self,call){if(!self){thrownewReferenceError("this hasn't been initialised - super() hasn't been called");}returncall&&(typeofcall==="object"||typeofcall==="function") ? call : self;}function_inherits(subClass,superClass){if(typeofsuperClass!=="function"&&superClass!==null){thrownewTypeError("Super expression must either be null or a function, not "+typeofsuperClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor: {value: subClass,enumerable: false,writable: true,configurable: true}});if(superClass)Object.setPrototypeOf ? Object.setPrototypeOf(subClass,superClass) : subClass.__proto__=superClass;}var_C=(_dec=(0,_index4.default)('Page'),_dec(_class=(_temp2=_class2=function(_Taro$Component){_inherits(_C,_Taro$Component);function_C(){var_ref;var_temp,_this,_ret;_classCallCheck(this,_C);for(var_len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}return_ret=(_temp=(_this=_possibleConstructorReturn(this,(_ref=_C.__proto__||Object.getPrototypeOf(_C)).call.apply(_ref,[this].concat(args))),_this),_this.$usedState=[],_this.state={},_this.componentWillMount=function(op){varid=op.id;console.log(id);},_this.config={},_this.$$refs=[],_temp),_possibleConstructorReturn(_this,_ret);}_createClass(_C,[{key: "_constructor",value: function_constructor(props){_get(_C.prototype.__proto__||Object.getPrototypeOf(_C.prototype),"_constructor",this).call(this,props);}},{key: "_createData",value: function_createData(){this.__state=arguments[0]||this.state||{};this.__props=arguments[1]||this.props||{};var__isRunloopRef=arguments[2];;Object.assign(this.__state,{});returnthis.__state;}}]);return_C;}(_index2.default.Component),_class2.properties={},_class2.$$events=[],_temp2))||_class);/** * Created by ryan on 2019/4/16. */exports.default=_C;Component(require('../../../npm/@tarojs/taro-weapp/index.js').default.createComponent(_C,true));
问题描述
[问题描述:站在其它人的角度尽可能清晰地、简洁地把问题描述清楚]
taro cli 1.2.22升级到1.2.26后,原生小程序先运行taro convert,然后运行 npm run dev:weapp后,在原来小程序onLoad函数里面如果存在参数op,想获得op里面的值会报错,Cannot read property 'id' of undefined
复现步骤
[复现问题的步骤]
1.taro convert
2.npm run dev:weapp
3.运行编译后的代码
[或者可以直接贴源代码,能贴文字就不要截图]
期望行为
[这里请用简洁清晰的语言描述你期望的行为]
返回undefined,而不是报错
报错信息
thirdScriptError
Cannot read property 'id' of undefined;at "pages/pages/test/test" page lifeCycleMethod onLoad function
TypeError: Cannot read property 'id' of undefined
at BaseComponent._this.componentWillMount (http://127.0.0.1:41160/appservice/pages/pages/test/test.js:44:18)
at componentTrigger (http://127.0.0.1:41160/appservice/npm/@tarojs/taro-weapp/dist/index.js:3517:100)
at updateComponent (http://127.0.0.1:41160/appservice/npm/@tarojs/taro-weapp/dist/index.js:3755:5)
at H.initComponent (http://127.0.0.1:41160/appservice/npm/@tarojs/taro-weapp/dist/index.js:3559:3)
at H.weappComponentConf.methods.onLoad (http://127.0.0.1:41160/appservice/npm/@tarojs/taro-weapp/dist/index.js:3651:21)
at H. (http://127.0.0.1:41160/appservice/__dev__/WAService.js:1:983107)
at H.p.callPageLifeTime (http://127.0.0.1:41160/appservice/__dev__/WAService.js:1:982866)
at kt (http://127.0.0.1:41160/appservice/__dev__/WAService.js:1:998756)
at http://127.0.0.1:41160/appservice/__dev__/WAService.js:1:1001435
at It (http://127.0.0.1:41160/appservice/__dev__/WAService.js:1:1001
[这里请贴上你的完整报错截图或文字]
系统信息
Taro CLI 1.2.26 environment info:
System:
OS: macOS 10.14.4
Shell: 5.3 - /bin/zsh
Binaries:
Node: 8.10.0 - ~/.nvm/versions/node/v8.10.0/bin/node
Yarn: 1.9.4 - /usr/local/bin/yarn
npm: 6.7.0 - ~/.nvm/versions/node/v8.10.0/bin/npm
npmGlobalPackages:
typescript: 3.1.6
weapp
补充信息
[可选]
[根据你的调查研究,出现这个问题的原因可能在哪里?]
The text was updated successfully, but these errors were encountered: