首页 > 解决方案 > VueJS 在 DOM 中渲染一些 v-binds(函数和数据)

问题描述

我在我的路由器视图上使用 v-bind 来获取要在组件中使用的一些数据对象和函数,有些工作完全符合预期,但有些工作出于某种原因被渲染到 DOM 中,我找不到它们的原因被渲染,而其他则没有。

这正常吗?或者我该如何解决这个问题?

Fe userString 和函数 userFunction 被渲染到路由器视图 div 中,但 otherUserString 不是。

<router-view
     v-bind:userString="userString"
     v-bind:userObject="userObject"
     v-bind:userFunction="userFunction"

     v-bind:otherUserString="otherUserString"
     v-bind:otherUserObject="otherUserObject"
     v-bind:otherUserFunction="otherUserFunction"
/>

我的结果如下(为了便于阅读而分解):

<div
     data-v-571e686
     userstring="XXXXXX"
     useraction="function () { [native code] }"
     userobject="[object Object]" >

我的预期是:

<div data-v-571e686>

标签: vue.jsvuejs2vue-router

解决方案


Vue Router 没有 userEncrypted 和 encryptUser 属性。https://router.vuejs.org/api/#exact-active-class

如果这是您的自定义组件,请确保已定义这些道具。


推荐阅读