Hello today i move to vue 3 with script setup.
I try use onBeforeMount for load external data (async await).
but receive error: "onBeforeMount is not defined"
I going to documentation and saw that onBeforeMount should work! what is problem ?

<script setup>
import { ref } from '@vue/reactivity';
import axios from 'axios';
var data = ref(null);
onBeforeMount(async () => {
data.value = await axios.get("url");
})
</script>
CodePudding user response:
It seems that you've missed to import it from vue :
<script setup>
import { ref} from '@vue/reactivity';
import {onBeforeMount } from 'vue'
import axios from 'axios';
var data = ref(null);
onBeforeMount(async () => {
data.value = await axios.get("url");
})
</script>
