依赖升级

  • vue -> 2.7.8
  • 删除vue-template-compiler,@vue/test-util 会用到,需要保留,同步版本和vue相同

this

  1. const { proxy } = getCurrentInstance()
  2. proxy.$router
  1. import { getCurrentInstance } from 'vue';
  2. // 访问vuex
  3. export const useStore = () => {
  4. const vm = getCurrentInstance();
  5. if (!vm) throw new Error('must be called in setup');
  6. return vm.proxy.$store;
  7. };
  8. // 访问router
  9. export const useRouter = () => {
  10. const vm = getCurrentInstance();
  11. if (!vm) throw new Error('must be called in setup');
  12. return vm.proxy.$router;
  13. };
  14. // 访问route
  15. export const useRoute = () => {
  16. const vm = getCurrentInstance();
  17. if (!vm) throw new Error('must be called in setup');
  18. return vm.proxy.$route;
  19. };

v-deep

  1. [@vue/compiler-sfc] ::v-deep usage as a combinator has been deprecated. Use :deep(<inner-selector>) instead

`