我正在运行带有webkit-polyfill-injector插件的AngularJS 1.7.5应用程序。 IE9和某些版本的Edge上会发生此问题。
IE控制台对此功能引发问题
function addScriptTag(identifier, json) {
//prep json
var pj = JSON.stringify(json);
//get existing
var tag = element[0].querySelector('script[identifier="' + identifier + '"]');
//update existing
if (tag) {
tag.innerText = pj;
return;
}
//create new
var newTag = document.createElement('script');
newTag.setAttribute("type", "application/ld+json");
newTag.setAttribute("identifier", identifier);
newTag.append(pj);
//add it
var logoScriptTag = element[0].querySelector('script[type="application/ld+json"]');
logoScriptTag.insertAdjacentElement('afterend', newTag);
}
这是一个webkit-polyfill-injector插件配置
var res = {
mode: 'development',
context: path.resolve(__dirname, ''),
entry:
{
app: `webpack-polyfill-injector?${JSON.stringify({
modules: ['./app/app.js']
})}!`
},
output: {
path: outputPath,
publicPath: '/web/',
filename: '[name].bundle.js',
chunkFilename: '[name].bundle.js'
},
devServer: {
contentBase: 'build',
host:'192.168.1.101',
port: devServerPort,
historyApiFallback: {
index: '/web/',
rewrites: [
{ from: /\/soccer/, to: '/soccer.html' }
]
},
watchContentBase: true
},
plugins: [
new PolyfillInjectorPlugin({
polyfills: [
'Promise',
'Array.prototype.find',
]
}),...
任何帮助将不胜感激!
答案 0 :(得分:0)
您可以尝试使用AngularJS jqLite附加项:
//create new
var newTag = document.createElement('script');
newTag.setAttribute("type", "application/ld+json");
newTag.setAttribute("identifier", identifier);
̶n̶e̶w̶T̶a̶g̶.̶a̶p̶p̶e̶n̶d̶(̶p̶j̶)̶;̶
angular.element(newTag).append(pj);
希望它不会与您的polyfill冲突。