vue-router - Vue3:通过 toRefs 访问 props 收到错误消息
问题描述
我在这里将 toRefs(props) 称为 vue 官方文档:https ://v3.vuejs.org/guide/composition-api-setup.html#props
但是 - 如果我使用低于 d.value 我在浏览器控制台中收到如下错误:
runtime-core.esm-bundler.js:38 [Vue 警告]:在 <DetailedView data="[{"Date":"2020-05","Scope":"EMEA ... .onVnodeUnmounted=fn ref=Ref<null >> at at
似乎已经收到了道具,但数据的访问是一个问题。
你能在这里阐明一下吗?
谢谢
@/router/index.ts
//this is the router definition, set the "props" as true, as to receive the parameters from the router as props
{
path: "/detailedview",
name: "DetailedView",
component: DetailedView,
props: true
}
@/component/overview.vue
//this is where the data is from. tableData is an ref array
import {router} from "@/router/index";
const data = JSON.stringify(tableData.value);
router.push({name:"DetailedView", params:{data: data}});
@/component/DetailedView.vue
//this is the router jump to = DetailedView
import {router} from "@/router/index";
export default defineComponent({
name: "DetailedView",
props: {data: String},
setup(props, { attrs, slots, emit }){
let { d }= toRefs(props)
console.log("d is:", d.value); //error message populate here
let m = props.data;
console.log("m is:", m); //OK. But it will remove props reactivity.
解决方案
推荐阅读
- logstash - Logstash 聚合过滤器插件无法正常工作
- c - 在 Win10 上使用 CodeBlocks 安装 GSL 库
- html - 所有 html 禁用按钮都具有禁用属性吗?
- javascript - 在节点 js 的同一端口上提供不同的静态页面实例
- r - 如何更改 R 中 2 个栅格图层的分辨率?
- reactjs - 反应材料ui的数据网格:可编辑列不起作用
- json - Jmeter提取具有包含和不包含条件的Json响应
- django - 从下拉菜单 django admin 中删除已注册的 celery 任务
- python - 将 TensorFlow Python 转换为 C# XOR 示例引发异常
- ios - 未能获得匹配的快照:失去与应用程序的连接