依赖升级
- vue -> 2.7.8
- 删除vue-template-compiler,@vue/test-util 会用到,需要保留,同步版本和vue相同
this
const { proxy } = getCurrentInstance()
proxy.$router
import { getCurrentInstance } from 'vue';
// 访问vuex
export const useStore = () => {
const vm = getCurrentInstance();
if (!vm) throw new Error('must be called in setup');
return vm.proxy.$store;
};
// 访问router
export const useRouter = () => {
const vm = getCurrentInstance();
if (!vm) throw new Error('must be called in setup');
return vm.proxy.$router;
};
// 访问route
export const useRoute = () => {
const vm = getCurrentInstance();
if (!vm) throw new Error('must be called in setup');
return vm.proxy.$route;
};
v-deep
[@vue/compiler-sfc] ::v-deep usage as a combinator has been deprecated. Use :deep(<inner-selector>) instead
`