下面是一个简单的示例,循环渲染生成二维码
<div ng-repeat="item in vm.content.links track by $index" >
<div id="{{item.name}}"></div>
</div>
const observer = new MutationObserver((mutations) => {
this.content.links.forEach((item) => {
new QRCode(item.name, {
text: item.url,
width: 150,
height: 150,
colorDark: "#000000",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.H
});
})
observer.disconnect();
});
observer.observe(document, { attributes: false, childList: true, characterData: false, subtree: true })