vue命名怎么获取
在 vue 中获取组件名称的两种方法:通过 this.$options.name 获取组件定义中的名称。通过 vm.$options.name 从 vue 实例中获取组件名称。
Vue 中如何获取组件名称
在 Vue 中,可以根据以下方法获取组件名称:
this.$options.name
此属性返回组件的名称,即在组件定义中使用的名称。
立即学习“前端免费学习笔记(深入)”;
示例:
export default { name: 'MyComponent', data() { console.log(this.$options.name); // 输出: "MyComponent" } };
发表评论