我在 springboot 项目中有一个 react 应用程序,react 应用程序使用 rest 调用来获取/设置内容。实际上,我已经在配置适配器中禁用了 csrf,.csrf().disable()但我想对此进行管理。我如何处理 react 和 springboot 之间的 csrf 令牌?
我认为我应该通过我的 axios 调用传递令牌,但是我如何得到它?
谢谢
vue 正在抛出此消息:
Vue 收到了一个组件,它是一个响应式对象。这会导致不必要的性能开销,应该通过用
markRaw或shallowRef代替 标记组件来避免ref。
<template>
<component v-for="(el, idx) in elements" :key="idx" :data="el" :is="el.component" />
</template>
setup() {
const { getters } = useStore()
const elements = ref([])
onMounted(() => {
fetchData().then((response) => {
elements.value = parseData(response)
})
})
return { parseData }
}
Run Code Online (Sandbox Code Playgroud)
有一个更好的方法吗?
const handleTestDelete = (id: any) => {
deleteTest(id).then(() => {
queryClient.invalidateQueries("test");
});
};
const columns = useMemo(
() => [
{ field: "id", headerName: "ID", width: 80 },
{
field: "",
width: 120,
disableClickEventBubbling: true,
sortable: false,
disableColumnMenu: true,
renderCell: (cell: any) => (
<>
<IconButton
aria-label="delete"
onClick={() => handleTestDelete(cell.id)}
>
<DeleteIcon fontSize="small" />
</IconButton>
<IconButton
aria-label="view"
onClick={() => history.push(`/something/${cell.id}/details`)}
>
<VisibilityIcon fontSize="small" />
</IconButton>
</>
),
},
],
[history]
Run Code Online (Sandbox Code Playgroud)
我收到此警告
React Hook useMemo 缺少依赖项:“handleTestDelete”。包含它或删除依赖项数组。
因为我没有添加在依赖项中单击删除按钮时调用的函数...为什么我应该将其作为依赖项?我什至不确定将历史作为依赖项是否正确;我认为当时间顺序发生变化时,不需要重新评估专栏
我错了?
谢谢
获取后,我需要使用一些数据更新反应对象:
setup(){
const formData = reactive({})
onMounted(() => {
fetchData().then((data) => {
if (data) {
formData = data //how can i replace the whole reactive object?
}
})
})
}
Run Code Online (Sandbox Code Playgroud)
formData = data 不会工作,而且 formData = { ...formdata, data }
有一个更好的方法吗?
i've a reactive object, on the save function i call toRaw in order to remove de object reactivity, but, when i change the reactive object props, also the group object is changing.... How???
const newGroup = reactive<Group>({ id: undefined, name: '', enabled: false })
const handleSave = () => {
const group = toRaw(newGroup)
persist(group).then(() => {
newGroup.id = undefined
newGroup.name = 'demo'
console.log(isReactive(group)) //say false but the group.name value is demo
})
}
Run Code Online (Sandbox Code Playgroud)
destructuring the reactive obj as const …