简体   繁体   English

Vuejs如何在组件中获取自定义定义对象

[英]Vuejs How can I get a custom define object in component

I want to use a custom object to instead of vue-meta 😂我想使用自定义对象来代替vue-meta 😂

Eg例如

<template>
  .....
</template>

<script>
export default {
  aboutMe: {}
}
</script>

How to get the custom define object aboutMe .如何获取自定义对象aboutMe

PS: But there is NOT data or computed PS:但没有datacomputed

Thank you!谢谢!

The object is available in the $options property:该对象在$options属性中可用:

mounted() {
  console.log(this.$options.aboutMe)
}

or或者

<template>
   <span> {{ $options.aboutMe }} </span>
</template>

But generally you'd want to add the object to the data :但通常您希望将对象添加到数据中:

data: () => ({
  aboutMe: {}
})

Then you can use {{ aboutMe }} and this.aboutMe然后你可以使用{{ aboutMe }}this.aboutMe

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

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