百度小程序转换微信小程序

Python脚本,一键转换
Github地址:https://github.com/DWmelon/py-transfer-BdToWxpython


运行条件

具有Python环境,可在命令行中使用Python命令git

使用方法

1. 转换工具 - mypy.pygithub

命令行输入: python mypy.py微信

 

2. 查找关键词工具 - findFileHaveX.py工具

命令行输入: python findFileHaveX.pyflex

 

转换规则

查看 mypy.py 源代码,能够很直观知道作了哪些修改,也就是你能够本身更新转换规则,欢迎一块儿维护this

 

百度与微信的区别

百度编译能经过而微信不能的状况

状况一:
Component({
  properties: {
    item: {
    //错误,需写明type、value等字段
    }
  },
  data: {
  },
  methods: {
  }
})

 

状况二:
<text class="{{(selectCourse[index1*3+index2]==1?'row_item_select':'row_item_unselect'}}">{{item}}</text>
#(selectCourse 多了一个左括号

 

状况三:
Setting data field "score" to undefined is invalid.
setData({}) 方法不容许赋 undefined

状况四:
#js中经过id获取组件
this.selectComponent("score") //错误
this.selectComponent("#score") //正确

 

状况五:
#xml中for循环
s-for="majorList" / s-for="{{majorList}}" //百度均可以
wx:for="{{majorList}}" //微信必须加{{}}

 

状况六:
//banner显示问题,事实上这个是日常都应该注意的细节
.banner {
  display: flex;
  flex:1;
  # flex-direction: column; //百度不写正常,微信不写不显示
  margin-top: 30rpx;
}

 

状况七:
userInfo = res.data.data.user_info; //百度编译经过并能正常赋值,相似Python
userInfo = res.data.data.user_info; //微信编译不经过,需加let/var定义变量
相关文章
相关标签/搜索