vue兼容谷歌48(含qiankun兼容)

本文介绍了如何在Vue项目中处理兼容性问题,包括在vue.config.js中配置es6转es5,解决css3变量的浏览器兼容,处理乾坤框架在老版本谷歌浏览器中的问题,以及解决qiankun微前端在谷歌48版本的加载错误。主要涉及了babel-polyfill、css-vars-ponyfill、whatwg-fetch等相关库的引入和配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

控制台定位到相应插件的js,找到插件:

1,在vue.config.js中配置:


'transpileDependencies': ['@jiaminghi/*',],

transpileDependencies为特别需要将es6代码翻译成es5的插件说明;

2,css3的var兼容:

npm install css-vars-ponyfill mutationobserver-shim —save


import 'mutationobserver-shim'
import cssVars from 'css-vars-ponyfill'
cssVars({
watch: true
})

3,乾坤兼容谷歌老版本,main.js中配置:(注意:子应用不能使用babel-polyfill)

npm install whatwg-fetch  custom-event-polyfill  core-js

import 'whatwg-fetch';

import 'custom-event-polyfill';

import 'core-js/stable/promise';

import 'core-js/stable/symbol';

import 'core-js/stable/string/starts-with';

import 'core-js/web/url';

4,qiankun兼容谷歌48版本,出现“

Application died in status LOADING_SOURCE_CODE: You need to export the functional lifecycles in xxx entry

解决: webpack output.library 配置成跟主应用中注册的 name 字段一致,如:

// 主应用中注册子应用
registerMicroApps([
  {
    name: 'brokenSubApp',
    entry: '//localhost:7100',
    container: '#yourContainer',
    activeRule: '/react',
  },
]);
//将微应用的 output.library 改为跟主应用中注册的一致:
module.exports = {
  output: {
    // 这里改成跟主应用中注册的一致
    library: 'brokenSubApp',
    libraryTarget: 'umd',
    jsonpFunction: `webpackJsonp_${packageName}`,
  },
};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值