This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { onBeforeMount, onMounted } from "vue"; | |
export default { | |
setup(){ | |
onBeforeMount(() => { | |
console.log("Before mount"); | |
}); | |
onMounted(() => { | |
console.log("Mounted"); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div>{{JSON.stringify(dataLocale)}}</div> | |
</template> | |
<script> | |
import locale from "@/composables/locale"; | |
export default { | |
async setup() { | |
const { getLocales } = await locale(); | |
const dataLocale = await getLocales(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Axios from "axios"; | |
export default function locale() { | |
async function getLocales() { | |
return await Axios.get( | |
"...url..." | |
).then((response) => { | |
return response.data; | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<Suspense> | |
<template #default> | |
<Locale /> | |
</template> | |
<template #fallback>Loading...</template> | |
</Suspense> | |
</template> | |
<script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ref } from "vue"; | |
export default function download() { | |
const filePath = ref(null); | |
function downloadBlob(){ | |
// any code here | |
} | |
function downloadJSON(){ | |
// any code here | |
} | |
return { filePath, downloadBlob, downloadJSON} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<!-- template code --> | |
</template> | |
<script> | |
import download from "@/use/download"; | |
import upload from "@/use/upload"; | |
export default { | |
setup(){ | |
return { ...download(), ...upload() } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ref } from "@vue/composition-api"; | |
export default function(fn) { | |
const result = ref(null); | |
const loading = ref(false); | |
const error = ref(null); | |
const createPromise = async (...args) => { | |
loading.value = true; | |
try { | |
result.value = await fn(...args); | |
} catch (err) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<input type="text" v-model="name" /> | |
</div> | |
</template> | |
<script> | |
export default { | |
data(){ | |
return { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<input type="text" v-model="name" /> | |
</div> | |
</template> | |
<script> | |
import { ref, watch } from "vue"; | |
export default { | |
setup() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<input type="text" v-model="name" /> | |
</div> | |
</template> | |
<script> | |
import { ref, watchEffect } from "vue"; | |
export default { | |
setup() { |
NewerOlder