关于绑定this的问题
源代码中的例子 /**
- Custom properties added to component instances in any way and can be accessed through
this
- @example
- Here is an example of adding a property
$router
to every component instance: - import { createApp } from 'vue'
- import { Router, createRouter } from 'vue-router'
- declare module '@vue/runtime-core' {
- interface ComponentCustomProperties {
$router: Router
- }
- }
- // effectively adding the router to every component instance
- const app = createApp({})
- const router = createRouter()
- app.config.globalProperties.$router = router
- const vm = app.mount('#app')
- // we can access the router from the instance
- vm.$router.push('/')
*/ export interface ComponentCustomProperties {}
我的项目是通过vue-cli4创建的,非class componet,目前发现例子中的声明只能放到main.ts中会剩下,放到shims-vue.d.ts中则会影响到如下声明: /* eslint-disable / declare module '.vue' { import type, { DefineComponent } from 'vue' const component: DefineComponent<{}, {}, any> export default component }
想资源下这大概是什么原因
Hello, thank you for taking time filling this issue!
However, we kindly ask you to use our Issue Helper when creating new issues, in order to ensure every issue provides the necessary information for us to investigate. This explains why your issue has been automatically closed by me (your robot friend!).
I hope to see your helper-created issue very soon!
你好,你的 issue 不符合我们所要求的格式,因此已被自动关闭。为了确保每个 issue 都提供必需的相关信息,请务必使用我们的 Issue 向导 来创建新 issue,谢谢!