[LayaAir 2.0]【Laya2.1BUG】 给view设置runtime后,类型是any
typescript项目,加载模式,新建一个Aview,把Aview拖到其他view中,设置Aview的runtime和var,发现生成的UI代码中Aview对应变量的类型是any
---------------------------------------------------------------------------------------------
下面是我修改2.1.0的源码resources\app\out\vs\layaEditor\h5\layabuilder.max.js
修改下面五个地方,即可解决上面的问题:
1,替换两个函数:
把
把
把
把
---------------------------------------------------------------------------------------------
下面是我修改2.1.0的源码resources\app\out\vs\layaEditor\h5\layabuilder.max.js
修改下面五个地方,即可解决上面的问题:
1,替换两个函数:
CodeManager.createTsSamePackageCode=function(packages,packageDic,preCode){2,修改CodeManager.objToUI函数:
var tPackage;
var i=0,len=0;
len=packages.length;
var packageCodes;
packageCodes=;
for(i=0;i<len;i++){
CodeManager.createTsSamePackageOne(packageCodes,packageDic[packages[i]]);
}
packageCodes.splice(0,0,preCode);
return packageCodes.join("\n");
}
CodeManager.createTsSamePackageOne=function(packageCodes,codeList){
var packageStart;
var packageEnd;
var tCode;
tCode=codeList[0];
var i=0,len=0;
len=codeList.length;
var tCodeLines;
var rstCodeList;
rstCodeList=;
var tStr;
var preStr="";
for(i=0;i<len;i++){
tCode=codeList<em>;
tCodeLines=tCode.split("\n");
tStr=tCodeLines.shift();
while(tStr.indexOf("export module")<0){
tStr=StringTool.trimSide(tStr);
if(preStr.indexOf(tStr)<0){
preStr+=tStr+"\n";
}
tStr=tCodeLines.shift();
}
if(i==0){
tCodeLines.splice(0,0,tStr);
}
if(i!=len-1){
tStr=tCodeLines.pop();
while(tStr.indexOf("}")<0){
tStr=tCodeLines.pop();
}
}
rstCodeList.push(tCodeLines.join("\n"));
}
preStr=StringTool.trimSide(preStr);
if(preStr!=""){
packageCodes.splice(0,0,preStr);
}
packageCodes.push(rstCodeList.join("\n"));
}
把
if(ProjectSetting.codeType==0){改成:
imports+=" import "+lib+";\n";
}
if(ProjectSetting.codeType==0){3,修改CodeManager.createTSVarByObj函数
imports+=" import "+lib+";\n";
}else if(this.projectSetting.codeType==1&&lib.lastIndexOf(".ts")==lib.length-3){
libName=lib.substring(lib.lastIndexOf("/")+1,lib.length);
if(libName.lastIndexOf(".")>=0){
libName=libName.substring(0,libName.lastIndexOf("."));
}
imports+=" import "+libName+" from '../"+lib.substring(0,lib.lastIndexOf("."))+"';\n";
}
把
var libName=lib.substring(lib.lastIndexOf(".")+1,lib.length);改成:
if(lib.lastIndexOf(".ts")==lib.length-3){
lib="any";
}
str+=" public "+a[0]+":"+lib+";\n";
var libName=lib.substring(lib.lastIndexOf("/")+1,lib.length);4,修改CodeTplManager.getCodeTpl函数
libName=libName.replace(/(\.ts)|(\.js)$/,"");
str+=" public "+a[0]+":"+libName+";\n";
把
case 1:改成:
tplStr=CodeTplManager.tsCodeTpl;
if(isEfc){
tplStr=CodeTplManager.tsCodeTplEfc;
}
else
if(isPreset){
tplStr=CodeTplManager.tsCodeTplPst;
}
break ;
case 1:5,搜索__proto.objToUI,找到这个函数
tplStr=CodeTplManager.tsCodeTpl;
if(isEfc){
tplStr=CodeTplManager.tsCodeTplEfc;
}
else
if(isPreset){
tplStr=CodeTplManager.tsCodeTplPst;
}
tplStr="{!imports!}\n"+tplStr;
break ;
把
if(this.projectSetting.codeType==0){改成:
imports+=" import "+lib+";\n";
}
if(this.projectSetting.codeType==0){
imports+=" import "+lib+";\n";
}else if(this.projectSetting.codeType==1&&lib.lastIndexOf(".ts")==lib.length-3){
libName=lib.substring(lib.lastIndexOf("/")+1,lib.length);
if(libName.lastIndexOf(".")>=0){
libName=libName.substring(0,libName.lastIndexOf("."));
}
imports+=" import "+libName+" from '../"+lib.substring(0,lib.lastIndexOf("."))+"';\n";
}
[i] [/i]
没有找到相关结果
已邀请:
要回复问题请先登录
1 个回复
Aar0n
赞同来自: