AngularJS 1.7.5 - 对象不支持 IE9 中的 属性 或方法 'append'
AngularJS 1.7.5 - Object doesn't support property or method 'append' in IE9
我是 运行 一个带有 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',
]
}),...
非常感谢任何帮助!
您可以尝试使用 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 冲突。
我是 运行 一个带有 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',
]
}),...
非常感谢任何帮助!
您可以尝试使用 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 冲突。