F
F
Flexx972021-12-01 12:03:10
Vue.js
Flexx97, 2021-12-01 12:03:10

How to pass an array and not a Vue3 proxy?

setup() {

    const beachData = ref([])
    const data = ref([])
    const dateDay = ref([])
    const month = ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь']
    const changedDay = computed(() => beachData.value)
    console.log(changedDay.value)



    onBeforeMount(() => {
      axios.get('https://api.binance.com/api/v1/klines?symbol=LTCBTC&interval=1M&limit=12')
          .then((res) => { // res.data = [213213, '12323', '32432432' ...]
            data.value.push((res.data.map(item => item.filter((item, idx) => idx === 0))))
            data.value[0].map((item) => {
              let date = new Date(item[0])
              beachData.value.push(month[date.getMonth()])
              console.log(beachData.value)
            })
          })
    })




    return {
    series: [{
      name: "Desktops",
      data: dateDay
    }],
    chartOptions: {
      chart: {
        height: 350,
        type: 'line',
        zoom: {
          enabled: false
        }
      },
      xaxis: {
        categories: changedDay.value
      }
    }
    }
  }


in this code i am accepting and filtering the request. before the component is mounted, I make a request, and I want to make a function that converts a 13-digit number into time, which I get. The problem is that when I pass this to the return object, it turns out that I am passing not an array with values, but a proxy. I can’t figure out how to deal with this, but if I just substitute my month variable (or a variable with a ref and a non-empty array) there, then everything will work. What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GrayHorse, 2021-12-01
@GrayHorse

toRaw()
https://v3.vuejs.org/api/basic-reactivity.html#toraw

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question