refactor(common,webview): remove redundant console logs and simplify api call
清理了两处页面和工具类中的调试日志,同时简化了uni.setNavigationBarTitle的调用代码,移除了不必要的success/fail回调,只保留核心调用逻辑
This commit is contained in:
@@ -1486,7 +1486,6 @@ export default {
|
||||
},
|
||||
|
||||
title(str) {
|
||||
console.log(`lang.js setNavigationBarTitle ---------------->`, str);
|
||||
if (str) {
|
||||
uni.setNavigationBarTitle({
|
||||
title: str,
|
||||
|
||||
@@ -11,6 +11,13 @@
|
||||
<script>
|
||||
import { decodeEntity } from '@/common/js/util.js';
|
||||
|
||||
|
||||
/**
|
||||
* 必须真机调试
|
||||
* 在微信模拟器中,行为和真机不一样
|
||||
* 1. 模拟器中,设置标题不生效,但是,在真机是可以的。
|
||||
*/
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -20,12 +27,9 @@ export default {
|
||||
};
|
||||
},
|
||||
onLoad(option) {
|
||||
console.log(`webview .......................................`)
|
||||
this.title = decodeURIComponent(option?.title ?? '');
|
||||
this.enableSetTitle = decodeURIComponent(option?.enable_set_title) == 1;
|
||||
|
||||
console.log(`webview -------------------`, { title: this.title, enableSetTitle: this.enableSetTitle });
|
||||
|
||||
// #ifdef H5
|
||||
this.src = decodeEntity(decodeURIComponent(option.src));
|
||||
// #endif
|
||||
@@ -35,7 +39,6 @@ export default {
|
||||
// #endif
|
||||
},
|
||||
onShow() {
|
||||
console.log('webview onShow ------------------------');
|
||||
this.updateNavbarTitle();
|
||||
},
|
||||
watch: {
|
||||
@@ -54,17 +57,8 @@ export default {
|
||||
},
|
||||
updateNavbarTitle(newTitle) {
|
||||
const title = newTitle ?? this.title;
|
||||
console.log('webview updateNavbarTitle', title);
|
||||
if (this.enableSetTitle) {
|
||||
uni.setNavigationBarTitle({
|
||||
title: title,
|
||||
success: function (res) {
|
||||
console.log('webview updateNavbarTitle success !!')
|
||||
},
|
||||
fail: function (err) {
|
||||
console.error('webview updateNavbarTitle fail !!', err);
|
||||
}
|
||||
});
|
||||
uni.setNavigationBarTitle({title});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user