gpt4 book ai didi

ecmascript-6 - `name` 中的 `export default` 是什么?

转载 作者:行者123 更新时间:2023-12-05 03:06:55 25 4
gpt4 key购买 nike

我正在寻找一个 vue 项目,一个 Users.vue , 在其 <script> , export defaultname: 'users' :

<template>

</template>

<script>

export default{
name:'users', // there is a `name: 'users'` key-value.
data(){
return {
users:[
{name:'Henry', position:'Web developer', show:false},
{name:'Henry', position:'Web developer', show:false},
{name:'Henry', position:'Web developer', show:false},
{name:'Henry', position:'Web developer', show:false},
{name:'Henry', position:'Web developer', show:false},
{name:'Henry', position:'Web developer', show:false},
{name:'Henry', position:'Web developer', show:false},
{name:'Henry', position:'Web developer', show:false}
]
}
},
components: {}
}
</script>

<style scoped>

</style>

我想知道 name: 'users' 是什么在那里发挥作用。之前,我看到其他项目,没有name: users在那里。


EDIT-1

我的意思是在 Users.vue , 是否 name: usersUsers.vue 有关?或者它只是 export default 中的一个元素?

最佳答案

来自doc :

Allow the component to recursively invoke itself in its template. Note that when a component is registered globally with Vue.component(), the global ID is automatically set as its name.

Another benefit of specifying a name option is debugging. Named components result in more helpful warning messages. Also, when inspecting an app in the vue-devtools, unnamed components will show up as , which isn’t very informative. By providing the name option, you will get a much more informative component tree.

它只适用于组件。在调试时指定一个名称选项,它有有用的警告消息。

关于ecmascript-6 - `name` 中的 `export default` 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48732088/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com