这是我的例子:
\n<template>\n <div v-for="id of SomethingChanging">\n {{ getSomethingAsync(id) }}\n </div>\n</template>\n\n<script>\nexport default {\n ...\n methods:{\n async getSomethingAsync(id){\n try {\n const result = await getSomethingAPI(id)\n return result.payload\n } catch (e) {\n console.log(e)\n }\n }\n }\n}\n</script>\n\nRun Code Online (Sandbox Code Playgroud)\n我们都知道, \xe2\x80\x8basync 函数将返回一个有希望的对象......
\n我该如何修复它以便页面返回真实的数据?
\n我是vue3的初学者。我们可以像这样使用动态组件:
<script setup>
import CommonLayout from "@/components/Layout/CommonLayout.vue";
</script>
<template>
<component :is="CommonLayout>
</component >
</template>
Run Code Online (Sandbox Code Playgroud)
我尝试使用这样的动态组件,但这是错误的:
<script setup>
import CommonLayout from "@/components/Layout/CommonLayout.vue";
</script>
<template>
<component :is="CommonLayout>
</component >
</template>
Run Code Online (Sandbox Code Playgroud)
<script setup>
import layouts from "@/components/Layout/index.js";
const { default: Layout } = await layouts["CommonLayout"]();
</script>
<template>
<Layout>
something
</Layout>
</template>
Run Code Online (Sandbox Code Playgroud)
没有错误捕获,但页面没有显示任何内容。布局与 CommonLayout 相同:
我想让 [POST] localhost/product 只是这个 API 跨域。
我不知道该怎么做
fastify.register(require('fastify-cors'), {
origin:'*',
methods:['POST'],
})
Run Code Online (Sandbox Code Playgroud)
这是我的 API:
{
method: 'POST',
url: '/product',
handler: productsController.addProduct,
},
Run Code Online (Sandbox Code Playgroud) 我尝试使用计算来观看 navigator.onLine 但在刷新网页之前无法工作?
<template><div>{{isOnline}}</div></template>
...
<scirpt>
...
computed: {
isOnline() {
return navigator.onLine;
},
},
...
</script>
Run Code Online (Sandbox Code Playgroud)