记录了Vue3使用过程中缓存频繁刷新的场景出现的问题及解决方法。要强制Vite重建依赖项,您可以使用--force命令行选项启动开发服务器,或者手动删除node_modules/.vite目录。这里我选择在package.json中写"scripts":{"dev":"vite--force"},vitebuild好像也受cache/src/main全局属性的影响可以通过appconfig绑定vue3import.globalProperties{createApp}from'vue'importaxiosfrom'axios'cre??ateApp(App).config.globalProperties.$http=axiosvue2importVuefrom'vue';importaxiosfrom'axios'Vue.prototype.$http=axios;AugmentingGlobalProperties如果使用ts扩展globalProperties的类型,构建时可能会报如下错误,Property'$http'doesnotexistontype'CreateComponentPublicInstance<...此时需要在src/shims-vue.d.在ts中添加如下语句,并确保tsconfig.json中包含shims-vue.d.ts文件Vue2中通过getCurrentInstance().proxy获取类似这样的引用复合api中的模板引用是指ref="comp1"对中子组件的引用,可以在setup获取constcomp1=ref(null)defineExposescript设置组件需要主动使用defineExpose({...})通过ref暴露外部引用使用的组件内属性(变量、方法...)$children$children实例属性已从Vue3.0中删除,不再受支持
