Subscribe on changes!

v-if behave differently in dev and production mode while some error occur

avatar
Nov 12th 2021

Version

3.2.21

Reproduction link

github.com/wxsms/vue3-vif-bug

Steps to reproduce

  1. pnpm i
  2. pnpm run dev, the page shows 2 title. which means only the error occur block was ignore during render.

image

  1. pnpm run build, and open the built page, the page shows only 1 title. which means the whole component was ignore during render.

image

What is expected?

dev and build shoud be consist, either 1 title or 2 title.

What is actually happening?

not consist.

avatar
Nov 12th 2021

You should commit the correct user value. eg:

onMounted(() => {
  store.commit('setUser', { name: 'username', roles: [] });
});
avatar
Nov 12th 2021

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.

avatar
Nov 12th 2021

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.