Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Chron's avatar
Level 6

Exclusion in Vue props

I want to pass config to a third-party method, like this new Partyconfig) except alertMessage

const config = defineProps([
	"name",
	"age",
	"place",
	"etc",
	"etc",
	"etc",
	"etc",
	.
	.
	.
	"alertMessage"
]);

Having a duplicate defineProps doesn't work, array functions don't work but I can do this

const ignoreArray = [
	"alertMessage",
];

const message = computed(() => {
	const obj = Object.entries(config).filter(([key, val]) => ignoreArray.includes(key));
	return Object.fromEntries(obj)
})

I feel like, probably, this is not the best solution. Any suggestions on what I can do with this?

0 likes
1 reply
RemiM's avatar

Why you don't use destructuring?

const config = defineProps({
  name: String,
  age: Number,
  place: String,
  ...
  alertMessage: String
});

const { alertMessage, ...filteredConfig } = config;

Now, you can use filteredConfig in the third-party method without having to deal with alertMessage.

1 like

Please or to participate in this conversation.