v-if behave differently in dev and production mode while some error occur
Version
3.2.21
Reproduction link
Steps to reproduce
pnpm i
pnpm run dev
, the page shows 2 title. which means only the error occur block was ignore during render.
pnpm run build
, and open the built page, the page shows only 1 title. which means the whole component was ignore during render.
What is expected?
dev and build shoud be consist, either 1 title or 2 title.
What is actually happening?
not consist.
You should commit the correct user value. eg:
onMounted(() => {
store.commit('setUser', { name: 'username', roles: [] });
});
You should commit the correct user value. eg:
onMounted(() => { store.commit('setUser', { name: 'username', roles: [] }); });
@ygj6 this is not the point, bad codes happends. The point is, it behave differently in development and production. which made the problem not being able to shown during development.
as @ygj6 pointed out, you need to provide valid values. Your code is throwing an error in development mode and it should not be overlooked. In production mode some optimizations take place for better performance and if you let errors pass through during development you cannot expect your application to work normally in development or production. In other words always fix any error reported during development.