-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Description
相关平台
字节跳动小程序
小程序基础库: 3.52.0.14
使用框架: React
复现步骤
import { useLaunch, usePageNotFound } from '@tarojs/taro';
import React from 'react';
import { Provider } from 'mobx-react';
import './app.scss';
import 'core-js/stable';
import userStore from "@common/store/user";
import VConsole from 'vconsole';
let uma = {};
if (typeof PRERENDER === 'undefined') {
if (process.env.TARO_ENV === 'weapp') {
uma = require('umtrack-wx');
uma.init({
appKey: 'XXXX',
useOpenid: true,
autoGetOpenid: true,
debug: false
});
}
}
//把uma 添加到Taro,后续通过Taro.uma调用uma方法 ,es6模块导入的是模块引用,
//因此放心注入,后面页面导入Taro模块是可以获取uma的
import Taro from '@tarojs/taro';
Taro.uma = uma;
//调用事件
// Taro.uma.trackEvent('bu7y', {
// name: 'car'
// });
function App({ children }) {
const store = { user: userStore };
useLaunch((option) => {
if (process.env.TARO_ENV === "h5" && option.query.vconsole) {
const vConsole = new VConsole();
}
if (!Taro.getStorageSync("src")) {
let src = process.env.TARO_ENV === "h5" ? "wap" : "yyxcxliebian";
Taro.setStorageSync("src", src);
}
if (process.env.TARO_ENV !== "h5") {
const updateManager = Taro.getUpdateManager()
if (updateManager.onCheckForUpdate) {
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
// console.log(res.hasUpdate)
})
updateManager.onUpdateReady(function () {
Taro.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success: function (res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
}
}
})
})
}
}
})
usePageNotFound((res) => {
Taro.switchTab({
url: '/pages/expo/index'
})
})
// children 是将要会渲染的页面
return (
<Provider {...store}>{children}
)
}
export default App
期望结果
var globalThis = webpack_require(/*! ../internals/global-this */ "./node_modules/core-js/internals/global-this.js");
期望 globalThis 对象内容和微信小程序保持一致
实际结果
var globalThis = webpack_require(/*! ../internals/global-this */ "./node_modules/core-js/internals/global-this.js");
globalThis对象缺少很多字段
环境信息
👽 Taro v3.6.20
Taro CLI 3.6.20 environment info:
System:
OS: Windows 11 10.0.22631
Binaries:
Node: 18.18.2 - C:\opensource\nodejs\node.EXE
npm: 9.8.1 - C:\opensource\nodejs\npm.CMD
npmPackages:
@tarojs/cli: 3.6.30 => 3.6.30
@tarojs/components: 3.6.30 => 3.6.30
@tarojs/helper: 3.6.30 => 3.6.30
@tarojs/plugin-framework-react: 3.6.30 => 3.6.30
@tarojs/plugin-html: 3.6.30 => 3.6.30
@tarojs/plugin-platform-alipay: 3.6.30 => 3.6.30
@tarojs/plugin-platform-h5: 3.6.30 => 3.6.30
@tarojs/plugin-platform-jd: 3.6.30 => 3.6.30
@tarojs/plugin-platform-qq: 3.6.30 => 3.6.30
@tarojs/plugin-platform-swan: 3.6.30 => 3.6.30
@tarojs/plugin-platform-tt: 3.6.30 => 3.6.30
@tarojs/plugin-platform-weapp: 3.6.30 => 3.6.30
@tarojs/react: 3.6.30 => 3.6.30
@tarojs/runtime: 3.6.30 => 3.6.30
@tarojs/shared: 3.6.30 => 3.6.30
@tarojs/taro: 3.6.30 => 3.6.30
@tarojs/taro-loader: 3.6.30 => 3.6.30
@tarojs/webpack5-runner: 3.6.30 => 3.6.30
@tarojs/with-weapp: 3.6.30 => 3.6.30
babel-preset-taro: 3.6.30 => 3.6.30
eslint-config-taro: 3.6.30 => 3.6.30
react: ^18.0.0 => 18.2.0

