I'm trying to get the ranks array of ranks_options from the useForm helper but it can't keep track of the current array
Please check below is my code
const form = useForm({ name: null, ranks: [], }); function addRanks() { form.ranks.push({ name: null, id:null}); } ranks_options = form.ranks.map(function (value) { return value.name; });
P粉5233350262023-09-17 19:32:36
Convert it to a computed property :
const ranks_options = computed(() => form.ranks.map(value => value.name)
This will set form.rank
as a dependency and recalculate its value when the dependency changes.