P粉1634659052023-08-27 11:13:36
I found that using attachTo: createContainer() when defining componentData can solve the problem. At the same time, whenever the wrapper is redefined, it must also be redefined.
const createContainer = (tag = "div") => { const container = document.createElement(tag); document.body.appendChild(container); return container; }; const componentData = { attachTo: createContainer(), store, localVue }; const wrapper = shallowMount(Index, componentData);