/api/show.js
export default defineEventHandler(async (event) => {
const cookie = getCookie(event, 'jwt')
console.log("cookie: " + cookie);
return { cookie: cookie }
})
Run Code Online (Sandbox Code Playgroud)
当我在浏览器中访问时,http://localhost:3000/api/show我可以在屏幕上看到正确的值,并且可以看到从服务器记录到控制台的正确值。
但是当我尝试在我的应用程序中使用它时,如下所示:
<script setup>
const { data } = await useFetch('/api/show')
console.log(data.value.cookie);
</script>
Run Code Online (Sandbox Code Playgroud)
然后两个控制台日志(服务器上的控制台日志和客户端上的控制台日志)都显示未定义。
这背后的逻辑是什么?
如何在 Nuxt3 中正确获取服务器上的 cookie 值?
我在 Nuxt 应用程序中有一个删除操作。成功删除后,我需要将用户重定向到另一个页面。但在 Nuxt路由器文档中,没有提到重定向。那么问题来了,在组件中如何实现呢?
我正在按照本教程进行操作,由于某种原因,我收到“最大调用堆栈错误”
<template>
<SearchInput></SearchInput>
</template>
<script>
import SearchInput from './components/SearchInput.vue'
export default {
name: 'App',
components:{
SearchInput
}
};
</script>
Run Code Online (Sandbox Code Playgroud)
SearchInput.vue组件文件:
<template>
<SearchInput>
<input type="text">
</SearchInput>
</template>
<script>
export default {
name: "SearchInput",
}
</script>
Run Code Online (Sandbox Code Playgroud)
我尝试为 SearchInput 指定自己的名称“SearchInputView”:SearchInput 但它不起作用。我使用 es6 语法,这是一个 Vue 2 项目。我究竟做错了什么?
我在 aspnet mvc 和 import vuejs v3 cdn 上有应用程序,我喜欢使用 vuetify 但我不知道该怎么做。这是我的代码示例
<!DOCTYPE html>
<html lang="en">
<head>
<title>@ViewData["Title"] - MVCAndVue</title>
<link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet">
<script src="https://unpkg.com/vue@next"></script>
</head>
<body>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>
<script>
const {
ref,
reactive,
} = Vue;
//Define Vue app
const App = {
data() {
return {
};
},
methods: {
},
setup(props, context) {
}
};
// Create new Vue app
const app = Vue.createApp(App);
app.mount("#app");
</script>
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Firebase 功能上制作一个应用程序(Puppeteer 应用程序),并且我在文件中有以下内容.json。它在本地运行良好。
"custom": {
"following_training": false,
"worked": false
}
Run Code Online (Sandbox Code Playgroud)
但是,当我远程推送它并尝试设置我的代码firebase functions:config:set app="$(cat .env-production.json)"(本质上避免输入长.json配置环境变量字符串)时,我确实收到以下警告:
HTTP Error: 400, Invalid value at 'variable.text' (TYPE_STRING), false
所以是的,它基本上告诉我只发送这种json:
"custom": {
"following_training": "false",
"worked": "false"
}
Run Code Online (Sandbox Code Playgroud)
然后,如果我添加那个to-bool 包来实际检查代码内部,它就会远程工作,如果toBool(local_vars.app.custom.worked) == false......
没有更干净的方法吗...?在 firebase config-env 文档中,实际上没有关于布尔字段的示例。
我在输入时确实得到了预期的内容firebase functions:config:get,但也很奇怪的是,我在 Google Cloud Platform 功能的仪表板中没有任何变量(我得到刷新的代码、Puppeteer 的选项设置等......)。
不确定是否有任何关系。
环境变量可能仅由 Firebase 使用,不需要发送到 GCP。
编辑:工作得很好,不是Firebase问题。