1

I want to create a 2-D array where the number of rows of the first dimension can be increased while clicking on a specific button.

<script setup>
...
//if define the table like that:
  var tab=ref([])
//this is the function called on the click
  function addrow(){
    tab.value.push()
    ...
  }
</script>

2 Answers2

0

i finally find the answer

<script setup>
...
//if define the table like that:
var tab=ref([ref([])])
//this is the function called on the click
function addrow(){
  tab.value.push(ref([]))
  ...
}
</script>
0

You don't need to add a ref, the tab's value is already a reactive array, just add an array:

<script setup>
...
//if define the table like that:
  var tab=ref([])
//this is the function called on the click
  function addrow(){
    tab.value.push([])
    ...
  }
</script>
Alexander Nenashev
  • 8,775
  • 2
  • 6
  • 17