简体   繁体   English

在 Vue 中刷新页面后如何修改道具值?

[英]How can I modify props values once the page has been refreshed in Vue?

My code is he following:他遵循我的代码:

I made this example.我做了这个例子。 The thing is I want to access props values in onMounted() but if I console.log(account.value.date) it says undefined.问题是我想访问 onMounted() 中的道具值,但如果我使用 console.log(account.value.date) 它说未定义。 So is there a way to modify props values before shown in template?那么有没有办法在模板中显示之前修改道具值?

Thank you!谢谢!

I just want to modify values I get from pops before they are shown in the page.我只想在页面显示之前修改从 pops 获得的值。

props in vue are read-only variables... if you want to modify the value you can copy it to a data variable and then change it in onMounted hook or wherever you want. vue 中的 props 是只读变量......如果你想修改值,你可以将它复制到一个数据变量,然后在 onMounted 钩子或任何你想要的地方改变它。

if you still want to modify the prop itself you can do it by emitting to the parent component to make the change by himself如果你仍然想修改道具本身,你可以通过发送到父组件来自己进行更改来完成

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM