網站首頁 編程語言 正文
Uncaught TypeError: Cannot read properties of undefined (reading ‘value‘),為什么沒實現出5來?
作者:hamimelon2020 更新時間: 2022-02-22 編程語言<!DOCTYPE html>
<div id="v-model-example" class="demo">
<todo-list></todo-list>
<todo-list-statistics></todo-list-statistics>
</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 milk']
}
},
provide() {
return {
todoLength: Vue.computed(() => this.todos.length)
}
},
template: `
<div>{{ todos.length }}</div>
`
})
app.component('todo-list-statistics', {
inject: ['todoLength'],
created() {
console.log(`Injected property: ${this.todoLength.value}`) // > 注入的 property: 5
}
}
).mount('#v-model-example')
</script>
<!DOCTYPE html>
<div id="v-model-example" class="demo">
<todo-list></todo-list>
<todo-list-statistics></todo-list-statistics>
</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 milk', 'Drink water']
}
},
provide() {
return {
todoLength: Vue.computed(() => this.todos.length)
}
},
template: `
<div>{{ todos.length }}</div>
`
})
app.component('todo-list-statistics', {
inject: ['todoLength'],
created() {
console.log(`Injected property: ${this.todoLength.value}`) // > 注入的 property: 5
}
}
).mount('#v-model-example')
</script>
原文鏈接:https://blog.csdn.net/weixin_40945354/article/details/123166373
相關推薦
- 2022-02-09 利用上下文屬性將?C++?對象嵌入?QML?里_C 語言
- 2022-07-23 C#中三種Timer計時器的詳細用法_C#教程
- 2024-04-03 linux系統配置nginx兩套以上的前端
- 2022-02-23 關于zabbix自定義監控項和觸發器問題_zabbix
- 2023-01-04 Android?Toolbar應用欄使用方法簡介_Android
- 2022-04-26 Python?Socket?編程知識點詳細介紹_python
- 2022-07-19 react表單處理之 非受控組件
- 2022-01-21 Docker報錯:OCI runtime exec failed: exec failed: con
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支