最近客户做的一个微信小程序,可以原来的开发者忘记给他源文件了,只能通过反编译uniapp找回原来的代码,特此记录一下反编译的过程
举例:
<view class="data-v-5310fc90">
<u-sticky bind:__l="__l" class="data-v-5310fc90" vueId="6199cf00-1" vueSlots="{{['default']}}">
<view class="u-border-bottom echo-top-tabsheight echo-bg-white data-v-5310fc90">
<u-tabs bind:__l="__l" bind:click="__e" class="data-v-5310fc90" current="{{tabscurrent}}" data-event-opts="{{[ [ '^click',[ ['tabsChange'] ] ] ]}}" list="{{tabslist}}" vueId="{{'6199cf00-2'+','+'6199cf00-1'}}"></u-tabs>
</view>
</u-sticky>
<u-empty bind:__l="__l" class="data-v-5310fc90" icon="/static/empty/data.png" iconSize="300" marginTop="50" mode="data" show="{{pempty}}" vueId="6199cf00-3"></u-empty>
<block wx:if="{{pempty==false}}">
<view class="data-v-5310fc90" wx:if="{{swiperlist!=null&&cateid==0}}">
<u-swiper bind:__l="__l" bind:click="__e" circular="{{true}}" class="data-v-5310fc90" data-event-opts="{{[ [ '^click',[ ['goSwiper'] ] ] ]}}" keyName="tilpic" list="{{swiperlist}}" vueId="6199cf00-4"></u-swiper>
</view>
<navigator class="data-v-5310fc90" url="{{'/pages/notice/detail?id='+item.id}}" wx:for="{{plist}}" wx:key="id">
<view class="u-flex u-flex-nowrap u-row-between u-padding-30 u-border-bottom echo-col-stretch data-v-5310fc90">
<view class="u-flex-1 u-flex u-flex-wrap echo-row-acontent data-v-5310fc90">
<view class="u-line-2 u-font-16 data-v-5310fc90">{{item.title}}</view>
<view class="u-flex u-flex-nowrap u-row-between u-font-12 u-light-color echo-width-fill u-padding-top-20 data-v-5310fc90">
<view class="data-v-5310fc90">{{item.mediaNoticeCate.name}}</view>
<view class="data-v-5310fc90" wx:if="{{item.priority>0}}">置顶</view>
</view>
</view>
</view>
</navigator>
<view class="u-padding-top-20 u-padding-bottom-40 data-v-5310fc90">
<u-loadmore bind:__l="__l" class="data-v-5310fc90" status="{{pstatus}}" vueId="6199cf00-5"></u-loadmore>
</view>
</block>
<echo-tabbar bind:__l="__l" class="data-v-5310fc90" tabber="{{vuex_tabbar}}" value="{{nowpage}}" vueId="6199cf00-6"></echo-tabbar>
</view>
编译后的代码:
<template>
<view>
<u-sticky vueId="6199cf00-1" :vueSlots="['default']" customNavHeight="0px" >
<view class="u-border-bottom echo-top-tabsheight echo-bg-white data-v-5310fc90" >
<u-tabs @click="tabsChange" :current="tabscurrent" :list="tabslist" :activeStyle="activeStyle" lineColor="#fa3534"></u-tabs>
</view>
</u-sticky>
<u-empty icon="/static/empty/data.png" iconSize="300" marginTop="50" mode="data" :show="pempty" ></u-empty>
<block v-if="pempty==false">
<view v-if="swiperlist!=null&&cateid==0">
<u-swiper :circular="true" keyName="tilpic" :list="swiperlist"></u-swiper>
</view>
<navigator :url="'/pages/notice/detail?id='+item.id" v-for="(item,index) in plist" :key="index">
<view
class="u-flex u-flex-nowrap u-row-between u-padding-30 u-border-bottom echo-col-stretch data-v-5310fc90">
<view class="u-flex-1 u-flex u-flex-wrap echo-row-acontent data-v-5310fc90">
<view class="u-line-2 u-font-16 data-v-5310fc90">{{item.title}}</view>
<view
class="u-flex u-flex-nowrap u-row-between u-font-12 u-light-color echo-width-fill u-padding-top-20 data-v-5310fc90">
<view>{{item.mediaNoticeCate.name}}</view>
<view v-if="item.priority>0">置顶</view>
</view>
</view>
</view>
</navigator>
<view class="u-padding-top-20 u-padding-bottom-40 data-v-5310fc90">
<u-loadmore :status="pstatus" vueId="6199cf00-5"></u-loadmore>
</view>
</block>
<!-- 与包裹页面所有内容的元素u-page同级,且在它的下方 -->
<u-tabbar v-if="tabbarlist" :value="nowpage" :activeColor="tabbarlist.activecolor"
@change="name => nowpage = name" :fixed="true" :placeholder="true" :safeAreaInsetBottom="true" >
<u-tabbar-item v-for="(item,index) in tabbarlist.list" :text="item.text" :key="index" :name="item.name" @click="goTabbar(item.pagePath)">
<image class="u-page__item__slot-icon" slot="active-icon" :src="item.selectedIconPath"></image>
<image class="u-page__item__slot-icon" slot="inactive-icon" :src="item.iconPath"></image>
</u-tabbar-item>
</u-tabbar>
</view>
</template>
<script>
export default {
data() {
return {
nowpage: uni.$u.page(),
tabbarlist: [],
tabslist: [],
tabscurrent: 0,
cateid: 0,
swiperlist: null,
loading: !1,
plist: [],
ppage: 1,
pstatus: "loadmore",
activeStyle:{
color: '#fa3534'
},
pempty: !0
}
},
onLoad: function() {
var o= this;
o.getTabber();
o.vuex_param = uni.getStorageSync('setting').param;
2 == o.vuex_param.pagenav.notice.status && 0 == o.vuex_memberinfo.id && uni.showModal({
title: "温馨提示",
showCancel: !1,
content: "你还未登录,无权浏览。请先注册登录...",
success: function(n) {
uni.$u.route({
type: "redirect",
url: "/pages/login/login"
});
}
}), uni.setNavigationBarTitle({
title: o.vuex_param.pagenav.notice.name
}), uni.$u.http.post("notice/pagenotice", {}).then(function(e) {
o.tabslist = e.catelist, o.swiperlist = e.swiperlist, o.pageRefresh();
});
},
methods: {
getTabber:function(){
var o = this;
o.tabbarlist = uni.getStorageSync('setting').tabbar;
},
goTabbar: function(n) {
console.log(n);
this.$u.route({
type: "reLaunch",
url: n
});
},
getMore: function() {
var o =this;
1 != o.loading && (o.loading = !0, uni.$u.http.post("notice/getnotice", {
cateid: o.cateid,
ppage: o.ppage
}).then(function(n) {
o.pstatus = n.pstatus, o.pempty = n.pempty, o.plist = o.plist.concat(n.plist), o.ppage += 1,
uni.stopPullDownRefresh(), o.loading = !1, o.loading = !1;
}));
},
pageRefresh: function() {
var o =this;
o.pstatus = "loadmore", o.ppage = 1, o.plist = [], o.getMore();
},
tabsChange: function(e) {
var o =this;
o.tabscurrent = e.index, o.cateid = e.id, o.pageRefresh();
},
goSwiper: function(n) {
var o =this;
var t = o.swiperlist[n];
uni.$u.route({
url: "/pages/notice/detail",
params: {
id: t.id
}
});
}
}
}
</script>
<style>
</style>
第一步 移除一些没有用的事件
bind:__l="__l"
第二步 将非标签里面的{{}}里面的转变为 vue 事件 如
wx:if="{{pempty==false}}"
转为
v-if ="pempty==false"
第三步 将小程序.js里面的onlod onShareAppMessage onShareTimeline onPullDownRefresh methods 等常用得到方法 移植到uniapp里面去 这些方法里面很容易替换 一般替换一个this 一个特殊定义的方法如uni
文章来源:https://www.toymoban.com/news/detail-546998.html
文章来源地址https://www.toymoban.com/news/detail-546998.html
到了这里,关于Uniapp编译后小程序的代码反编译一些思路的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!