抄一个,还没明白用法和意思
作者:互联网
<div id="app">
<todo-list></todo-list>
</div>
<script src="https://unpkg.com/vue@next"></script>
<script>
const app = Vue.createApp({});
app.component('todo-list', {
data() {
return {
todos: ['Feed a cat', 'Buy tickets', 'Have luntch']
}
},
provide: {
user: 'John Doe'
},
provide() {
return {
todoLength: this.todos.length
}
},
template: `
<div>
{{ todos.length }}
<!-- 模板的其余部分 -->
</div>
`
})
app.component('todo-list-statistics', {
inject: ['user'],
created() {
console.log(`Injected property: ${this.user}`) // > 注入 property: John Doe
}
})
app.mount('#app')
</script>
todos.length可以换成todos
还没明白用法和意思
标签:app,length,用法,意思,明白,John,todo,todos,user 来源: https://blog.csdn.net/weixin_40945354/article/details/119394039