我们正在使用一个翻译库,它将这两个东西添加到我的页面中。
<html lang="en" class="notranslate translated-ltr">
<meta name="google" content="notranslate">正因为如此,内置的浏览器翻译无法正常工作。对于特定的div,我们也希望使用浏览器翻译。当我通过inspect元素添加这行代码时
<div translate="yes">Some non-english Content</div>它解决了这个问题。但是在我的Vue 2应用程序中添加相同的内容,会将添加的属性值更改为
<div translate="translate">Some non-english Content</div>正因为如此,它再一次不起作用。在这种情况下,有人能帮我吗?
编辑:我们在Vue 2.5.17 :(
发布于 2021-07-17 06:11:01
将Vue从2.5.17升级到2.6.14解决了此问题。但这破坏了应用程序的多种功能。
或者,DOM操作在没有升级的情况下解决了问题。
allowTranslation(){
const messageContainer = document.querySelectorAll('.allowTranslate');
messageContainer.forEach(box => {
let allAttributes = [...box.attributes];
if(!allAttributes.includes('translate')){
box.setAttribute('translate', 'yes')
}
})
}https://stackoverflow.com/questions/68355878
复制相似问题